扁平化优化更新
This commit is contained in:
@@ -531,51 +531,27 @@ namespace Demo
|
||||
Update
|
||||
}
|
||||
|
||||
private string s_ScriptUpdateZoneName = null;
|
||||
private string s_UpdateTicksZoneName = null;
|
||||
public string ScriptUpdateZoneName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_ScriptUpdateZoneName == null)
|
||||
s_ScriptUpdateZoneName = $"{m_ScriptType}.ScriptUpdate";
|
||||
return s_ScriptUpdateZoneName;
|
||||
}
|
||||
}
|
||||
public string UpdateTicksZoneName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_UpdateTicksZoneName == null)
|
||||
s_UpdateTicksZoneName = $"{m_ScriptType}.UpdateTicks";
|
||||
return s_UpdateTicksZoneName;
|
||||
}
|
||||
}
|
||||
|
||||
[Content, SerializeField] private int ScriptUpdateCounter = 0;
|
||||
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
if (IsScriptApply == false)
|
||||
return;
|
||||
|
||||
using (Profiler.BeginZone(ScriptUpdateZoneName))
|
||||
if (tickType == TickType.Reset)
|
||||
{
|
||||
if (tickType == TickType.Reset)
|
||||
ResetEnterGameStatus();
|
||||
foreach (var child in Childs)
|
||||
{
|
||||
ResetEnterGameStatus();
|
||||
foreach (var child in Childs)
|
||||
{
|
||||
child.ScriptUpdate(currentTime, deltaTime, tickType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// UpdateTicks
|
||||
if (ScriptUpdateCounter % UpdatePerFrame == 0)
|
||||
UpdateTicks(currentTime, deltaTime, tickType);
|
||||
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
|
||||
child.ScriptUpdate(currentTime, deltaTime, tickType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// UpdateTicks
|
||||
if (ScriptUpdateCounter % UpdatePerFrame == 0)
|
||||
UpdateTicks(currentTime, deltaTime, tickType);
|
||||
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
|
||||
@@ -637,7 +613,13 @@ namespace Demo
|
||||
// 统计更新能力
|
||||
{
|
||||
if (this.IsSelfEnableUpdate)
|
||||
GetRoot().UpdateChilds.Add(this);
|
||||
{
|
||||
var type = this.GetType();
|
||||
if (GetRoot().UpdateChilds.TryGetValue(type, out var scriptables))
|
||||
scriptables.Add(this);
|
||||
else
|
||||
GetRoot().UpdateChilds[type] = new() { this };
|
||||
}
|
||||
}
|
||||
IsScriptApply = true;
|
||||
}
|
||||
@@ -862,7 +844,6 @@ namespace Demo
|
||||
{
|
||||
base.UpdateTicks(currentTime, deltaTime, tickType);
|
||||
// 存在严重的性能开销, 在解决之前将不会允许其快速自动更新
|
||||
using (Profiler.BeginZone($"{nameof(TimelineScriptObject)}.{nameof(MyTimelineItem.ResizeOnTimeline)}"))
|
||||
{
|
||||
if (UIResizeOnTimelineCount > 0.1 || tickType != TickType.Update)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user