添加Tracy0.11的性能分析支持

This commit is contained in:
2025-11-27 17:18:30 +08:00
parent 92c5c7f795
commit 0d856db69a
56 changed files with 4045 additions and 505 deletions

View File

@@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Unity.Profiling;
using UnityEngine;
namespace Demo
@@ -276,9 +275,6 @@ namespace Demo
public void EnableScript(ScriptableObject parent)
{
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker = new(ScriptName);
#endif
if (isEnableScript)
{
Debug.LogError($"ScriptableObject is currently enableScript, start coroutine {nameof(UnloadScript)} to disable", this);
@@ -328,11 +324,6 @@ namespace Demo
public static Dictionary<string, Type> FastScriptableObjectTypen = new();
public static int AllScriptableObjectCounter = 0;
#if UNITY_EDITOR||Using_ProfilerMarker
public ProfilerMarker s_PreparePerfMarker;
#endif
#region LoadSubScript
/// <summary>
@@ -471,28 +462,26 @@ namespace Demo
return;
if (gameObject.activeInHierarchy == false)
return;
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.Begin(this);
#endif
if (tickType == TickType.Reset)
using (Profiler.BeginZone($"{GetType().Name}.Update"))
{
ResetEnterGameStatus();
if (tickType == TickType.Reset)
{
ResetEnterGameStatus();
}
// UpdateTicks
if (UpdatePerFrame > 0)
{
if (ScriptUpdateCounter % UpdatePerFrame == 0)
UpdateTicks(currentTime, deltaTime, tickType);
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
}
// Childs UpdateTicks
foreach (var child in Childs)
{
child.ScriptUpdate(currentTime, deltaTime, tickType);
}
}
// UpdateTicks
if (UpdatePerFrame > 0)
{
if (ScriptUpdateCounter % UpdatePerFrame == 0)
UpdateTicks(currentTime, deltaTime, tickType);
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
}
// Childs UpdateTicks
foreach (var child in Childs)
{
child.ScriptUpdate(currentTime, deltaTime, tickType);
}
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.End();
#endif
}
protected virtual void UpdateTicks(float currentTime, float deltaTime, TickType tickType)