2022-07-04 15:29:19 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Editor.Track;
|
|
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Editor
|
|
|
|
{
|
2022-08-27 03:43:01 +00:00
|
|
|
public class SnapDialog : Dialog
|
2022-07-04 15:29:19 +00:00
|
|
|
{
|
|
|
|
[SerializeField] private TMP_Text snapText;
|
|
|
|
private Timeline timeline;
|
|
|
|
|
|
|
|
private static float[] CommonDenominators = { 1, 2, 3, 4, 6, 8, 12, 16};
|
|
|
|
private int currentCommon = 3;
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
timeline = Timeline.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SwitchSnapDialog()
|
|
|
|
{
|
2022-08-27 03:43:01 +00:00
|
|
|
if(dialog.activeSelf) {
|
|
|
|
dialog.SetActive(false);
|
2022-07-04 15:29:19 +00:00
|
|
|
} else {
|
2022-08-27 03:43:01 +00:00
|
|
|
ResetAllDialogs();
|
|
|
|
dialog.SetActive(true);
|
2022-07-04 15:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ChangeCommon(bool down = false)
|
|
|
|
{
|
|
|
|
if(down) {
|
|
|
|
currentCommon--;
|
|
|
|
} else {
|
|
|
|
currentCommon++;
|
|
|
|
}
|
|
|
|
if(currentCommon < 0) {
|
|
|
|
currentCommon = 0;
|
|
|
|
} else if(currentCommon >= CommonDenominators.Length) {
|
|
|
|
currentCommon = CommonDenominators.Length - 1;
|
|
|
|
}
|
|
|
|
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
snapText.text = $"1/{CommonDenominators[currentCommon]}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|