fully functional snap change menu

This commit is contained in:
minenice55
2022-07-04 11:29:19 -04:00
parent 70a335da5d
commit 21c175d025
13 changed files with 559 additions and 55 deletions

View File

@ -1,28 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Editor
{
public class SnapDialog : MonoBehaviour
{
[SerializeField] private GameObject snapSetter;
private void Awake()
{
}
public void SwitchSnapDialog()
{
if(snapSetter.activeSelf) {
snapSetter.SetActive(false);
} else {
snapSetter.SetActive(true);
}
}
private void Update()
{
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 537580972fcefa548bd9ee5e8254cbfc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace HeavenStudio.Editor
{
public class SnapChangeButton : Button, IPointerDownHandler
{
public SnapDialog SnapDialog;
public bool isDown;
public override void OnPointerDown(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Left)
{
SnapDialog.ChangeCommon(isDown);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7e0cac45de7228a4c8f7bc6adb0751a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Editor.Track;
using TMPro;
namespace HeavenStudio.Editor
{
public class SnapDialog : MonoBehaviour
{
[SerializeField] private GameObject snapSetter;
[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()
{
if(snapSetter.activeSelf) {
snapSetter.SetActive(false);
} else {
snapSetter.SetActive(true);
}
}
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]}";
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36b14c8563ea37442aa7a2f0342549b5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -30,6 +30,8 @@ namespace HeavenStudio.Editor.Track
public static float SnapInterval() { return instance.snapInterval; }
public void SetSnap(float snap) { snapInterval = snap; }
public class CurrentTimelineState
{
public bool selected;