优化
This commit is contained in:
@@ -51,10 +51,22 @@ public class FlexibleFloatTab : MonoBehaviour
|
||||
// 创建节拍线
|
||||
private void CreateBeatLines()
|
||||
{
|
||||
for (int i = 0; i < (int)EditorManager.instance.songInformation.song.length / FatherWindow.timePerBeat; i++)
|
||||
// 先清空BeatArea下的所有子对象,防止重复生成
|
||||
for (int i = BeatArea.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(BeatArea.GetChild(i).gameObject);
|
||||
}
|
||||
float maxX = 1400f + (3 * BeatDeviver);
|
||||
int totalBeats = (int)(EditorManager.instance.songInformation.song.length / FatherWindow.timePerBeat);
|
||||
for (int i = 0; i < totalBeats; i++)
|
||||
{
|
||||
float posX = BeatDeviver * i;
|
||||
if (posX > maxX)
|
||||
{
|
||||
break;
|
||||
}
|
||||
GameObject u = Instantiate(BeatLine, BeatArea);
|
||||
u.transform.localPosition = new Vector3(BeatDeviver * i, 0, 0);
|
||||
u.transform.localPosition = new Vector3(posX, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +94,15 @@ public class FlexibleFloatTab : MonoBehaviour
|
||||
Vector3 newPosition = new Vector3(-FatherWindow.songBeat * BeatDeviver, 0, 0);
|
||||
Area.localPosition = newPosition;
|
||||
BeatArea.localPosition = newPosition;
|
||||
XBeatArea.localPosition = newPosition;
|
||||
while (true)
|
||||
{
|
||||
BeatArea.localPosition += new Vector3(BeatDeviver, 0, 0);
|
||||
if (BeatArea.localPosition.x > ((-200f) - BeatDeviver))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
XBeatArea.localPosition = BeatArea.localPosition;
|
||||
}
|
||||
|
||||
// 添加事件
|
||||
@@ -141,7 +161,7 @@ public class FlexibleFloatTab : MonoBehaviour
|
||||
public float GetBeat()
|
||||
{
|
||||
// 获取鼠标在 BeatArea 中的相对位置
|
||||
Vector2 localMousePosition = BeatArea.InverseTransformPoint(Mouse.current.position.ReadValue());
|
||||
Vector2 localMousePosition = Area.InverseTransformPoint(Mouse.current.position.ReadValue());
|
||||
//Debug.Log(localMousePosition);
|
||||
|
||||
float mouseBeat = localMousePosition.x / BeatDeviver;
|
||||
|
||||
Reference in New Issue
Block a user