Files
Convention-Unity-Demo/Assets/Scripts/Framework/EditiorContent/BPMLine.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2025-09-25 19:04:05 +08:00
using Convention.WindowsUI;
using TMPro;
using UnityEngine;
namespace Demo.Editor
{
public class BPMLine : MonoBehaviour
{
private UnityEngine.UI.Text MyText;
private UnityEngine.UI.Image MyView;
private RectTransform MyRectTransform;
private void Awake()
{
MyText = GetComponentInChildren<UnityEngine.UI.Text>();
MyRectTransform = GetComponent<RectTransform>();
MyView = GetComponent<UnityEngine.UI.Image>();
}
public void Setup(float time, float currentTime, float onebar,float farAlpha, Vector2 clip)
{
gameObject.SetActive(true);
var t = (time - clip.x) / (clip.y - clip.x);
if (Mathf.Abs(time - currentTime) < 4 * onebar)
{
MyText.gameObject.SetActive(true);
MyText.text = time.ToString();
MyView.color = new(1, 1, 1, 1);
}
else
{
MyText.gameObject.SetActive(false);
MyView.color = new(1, 1, 1, farAlpha);
}
MyRectTransform.anchorMin = new(t, 0);
MyRectTransform.anchorMax = new(t, 1);
}
}
}