更新优化 扁平化+静态剪枝
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Demo.Game
|
||||
{
|
||||
public class RootObject : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
[Content] public List<ScriptableObject> UpdateChilds = new();
|
||||
[Resources] public BasicAudioSystem audioSystem;
|
||||
|
||||
[Content] public GameController RootGameController;
|
||||
@@ -33,6 +35,7 @@ namespace Demo.Game
|
||||
Keyboard.current.onTextInput -= InputCatchChar;
|
||||
}
|
||||
yield return base.UnloadScript();
|
||||
UpdateChilds.Clear();
|
||||
}
|
||||
|
||||
public void EnableScript(string sourcePath, GameController parent)
|
||||
@@ -82,27 +85,25 @@ namespace Demo.Game
|
||||
{
|
||||
if (RootGameController.IsMain)
|
||||
{
|
||||
void Foo()
|
||||
if (RootGameController.IsAutoPlay)
|
||||
return;
|
||||
if (RootGameController.MainAudio.IsPlaying() == false)
|
||||
return;
|
||||
// 更新缓存时间
|
||||
CurrentUpdateTickTimePoint = currentTime;
|
||||
// 将距离当前更近的输入调整到更靠前的位置
|
||||
InputCatch.Sort((x, y) => Mathf.Abs(x.TimePoint - currentTime).CompareTo(y.TimePoint - currentTime));
|
||||
if (InputCatch.Count > 50)
|
||||
InputCatch = InputCatch.GetRange(0, 50);
|
||||
if (tickType == TickType.Start)
|
||||
{
|
||||
if (RootGameController.IsAutoPlay)
|
||||
return;
|
||||
if (RootGameController.MainAudio.IsPlaying() == false)
|
||||
return;
|
||||
// 更新缓存时间
|
||||
CurrentUpdateTickTimePoint = currentTime;
|
||||
// 将距离当前更近的输入调整到更靠前的位置
|
||||
InputCatch.Sort((x, y) => Mathf.Abs(x.TimePoint - currentTime).CompareTo(y.TimePoint - currentTime));
|
||||
if (InputCatch.Count > 50)
|
||||
InputCatch = InputCatch.GetRange(0, 50);
|
||||
if (tickType == TickType.Start)
|
||||
{
|
||||
InputCatch.Clear();
|
||||
}
|
||||
InputCatch.Clear();
|
||||
}
|
||||
|
||||
Foo();
|
||||
}
|
||||
base.UpdateTicks(currentTime, deltaTime, tickType);
|
||||
foreach (var item in UpdateChilds)
|
||||
{
|
||||
item.ScriptUpdate(currentTime, deltaTime, tickType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user