@@ -22,38 +22,31 @@ namespace Ichni.RhythmGame
|
||||
pendingNotes.Sort((a, b) => a.activationTime.CompareTo(b.activationTime));
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
void Update()
|
||||
{
|
||||
List<(NoteBase note, float activationTime, float finishTime)> toRemove = new List<(NoteBase, float, float)>();
|
||||
foreach ((NoteBase note, float activationTime, float finishTime) in pendingNotes)
|
||||
|
||||
float currentTime = EditorManager.instance.songInformation.songTime;
|
||||
|
||||
// 一次性移除所有 null 项
|
||||
pendingNotes.RemoveAll(item => item.note == null);
|
||||
|
||||
foreach (var item in pendingNotes)
|
||||
{
|
||||
if (note == null)
|
||||
{
|
||||
toRemove.Add((note, activationTime, finishTime));
|
||||
continue;
|
||||
}
|
||||
if (EditorManager.instance.songInformation.songTime >= activationTime &&
|
||||
EditorManager.instance.songInformation.songTime <= finishTime)
|
||||
{
|
||||
if (!note.gameObject.activeSelf)
|
||||
{
|
||||
var (note, activationTime, finishTime) = item;
|
||||
bool shouldBeActive = currentTime >= activationTime && currentTime <= finishTime;
|
||||
bool isActive = note.gameObject.activeSelf;
|
||||
|
||||
note.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (shouldBeActive && !isActive)
|
||||
{
|
||||
note.gameObject.SetActive(true);
|
||||
}
|
||||
else if (!shouldBeActive && isActive)
|
||||
{
|
||||
if (note.gameObject.activeSelf)
|
||||
{
|
||||
note.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
note.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
for (int i = toRemove.Count - 1; i >= 0; i--)
|
||||
{
|
||||
pendingNotes.Remove(toRemove[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user