同步
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ObjectTracker : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class ParticleTracker : GameElement, IHaveParticles, IHaveColorSubmodule
|
||||
public partial class ParticleTracker : GameElement, IHaveParticles, IHaveColorSubmodule, IScheduledElement
|
||||
{
|
||||
#region [暴露属性字段] Essential Configs
|
||||
public Track track;
|
||||
@@ -66,6 +66,18 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
colorSubmodule = new ColorSubmodule(this, Color.white, true, Color.white, 0);
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
base.AfterInitialize();
|
||||
CoreServices.UpdateScheduler.Register(UpdatePhase.Effect, this);
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
base.OnDelete();
|
||||
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [运行时设置] Runtime Settings
|
||||
@@ -91,9 +103,8 @@ namespace Ichni.RhythmGame
|
||||
#region [轮询更新] Main Update
|
||||
public partial class ParticleTracker
|
||||
{
|
||||
private void Update()
|
||||
private void UpdateParticlePlayState(float songTime)
|
||||
{
|
||||
float songTime = CoreServices.TimeProvider.SongTime;
|
||||
if (playTime > songTime || stopTime < songTime)
|
||||
{
|
||||
particle.Stop();
|
||||
@@ -106,6 +117,15 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region [IScheduledElement] Scheduler Interface
|
||||
public void ScheduledUpdate(UpdatePhase phase, float songTime)
|
||||
{
|
||||
UpdateParticlePlayState(songTime);
|
||||
}
|
||||
|
||||
public bool IsScheduledActive => isActiveAndEnabled;
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user