mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 10:47:39 +02:00
fully functional snap change menu
This commit is contained in:
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/LevelEditor/SnapDialog.meta
Normal file
8
Assets/Scripts/LevelEditor/SnapDialog.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537580972fcefa548bd9ee5e8254cbfc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Scripts/LevelEditor/SnapDialog/SnapChangeButton.cs
Normal file
22
Assets/Scripts/LevelEditor/SnapDialog/SnapChangeButton.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e0cac45de7228a4c8f7bc6adb0751a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
52
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs
Normal file
52
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs
Normal 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]}";
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/LevelEditor/TempoFinder.meta
Normal file
8
Assets/Scripts/LevelEditor/TempoFinder.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36b14c8563ea37442aa7a2f0342549b5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
|
Reference in New Issue
Block a user