mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 11:57:40 +02:00
fully functional snap change menu
This commit is contained in:
43
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs
Normal file
43
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class TempoFinder : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject tempoFinder;
|
||||
private bool pressed;
|
||||
private float timePressed;
|
||||
[SerializeField] private BPMText bpmText;
|
||||
private void Awake()
|
||||
{
|
||||
pressed = false;
|
||||
timePressed = 0f;
|
||||
}
|
||||
public void SwitchTempoDialog()
|
||||
{
|
||||
if(tempoFinder.activeSelf) {
|
||||
tempoFinder.SetActive(false);
|
||||
timePressed = 0;
|
||||
bpmText.ResetText();
|
||||
} else {
|
||||
tempoFinder.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void TapBPM()
|
||||
{
|
||||
pressed = true;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
timePressed += Time.deltaTime;
|
||||
if(pressed)
|
||||
{
|
||||
pressed = false;
|
||||
bpmText.ChangeText(timePressed);
|
||||
timePressed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b489f3aef16a65499f9596abda39c35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Scripts/LevelEditor/TempoFinder/TempoFinderButton.cs
Normal file
20
Assets/Scripts/LevelEditor/TempoFinder/TempoFinderButton.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class TempoFinderButton : Button, IPointerDownHandler
|
||||
{
|
||||
public TempoFinder tempoFinder;
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
tempoFinder.TapBPM();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9557e460670800e458d7bb141135de55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user