重构前夕

This commit is contained in:
2025-10-13 23:54:29 +08:00
parent fca81c514a
commit c23cefd867
4 changed files with 34 additions and 15 deletions

View File

@@ -16,7 +16,7 @@ namespace Demo.Editor
{ {
public class EditorController : MonoSingleton<EditorController> public class EditorController : MonoSingleton<EditorController>
{ {
#if UNITY_EDITOR #if UNITY_EDITOR||Using_ProfilerMarker
public ProfilerMarker s_PreparePerfMarker = new(nameof(EditorController) + "Runtime"); public ProfilerMarker s_PreparePerfMarker = new(nameof(EditorController) + "Runtime");
#endif #endif
@@ -467,7 +467,7 @@ namespace Demo.Editor
{ {
CurrentFPS.text = $"{1 / Time.smoothDeltaTime}"; CurrentFPS.text = $"{1 / Time.smoothDeltaTime}";
#if UNITY_EDITOR #if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.Begin(this); s_PreparePerfMarker.Begin(this);
try try
{ {
@@ -530,7 +530,7 @@ namespace Demo.Editor
CloseCurrentProject(); CloseCurrentProject();
} }
} }
#if UNITY_EDITOR #if UNITY_EDITOR||Using_ProfilerMarker
} }
finally finally
{ {

View File

@@ -278,8 +278,10 @@ namespace Demo.Game
private bool IsScrollTimeline = false; private bool IsScrollTimeline = false;
#if UNITY_EDITOR||Using_ProfilerMarker
public ProfilerMarker s_PreparePerfMarkerForSetSongCurrentTime = new(nameof(GameController) + "RuntimeForSetSongCurrentTime"); public ProfilerMarker s_PreparePerfMarkerForSetSongCurrentTime = new(nameof(GameController) + "RuntimeForSetSongCurrentTime");
public ProfilerMarker s_PreparePerfMarker = new(nameof(GameController) + "Runtime"); public ProfilerMarker s_PreparePerfMarker = new(nameof(GameController) + "Runtime");
#endif
private void Update() private void Update()
{ {
@@ -293,15 +295,21 @@ namespace Demo.Game
// TODO : 修正这个逻辑,这个逻辑是反常的 // TODO : 修正这个逻辑,这个逻辑是反常的
if (MainAudio.IsPlaying()) if (MainAudio.IsPlaying())
{ {
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarkerForSetSongCurrentTime.Begin(); s_PreparePerfMarkerForSetSongCurrentTime.Begin();
#endif
SetSongCurrentTime(CurrentTime); SetSongCurrentTime(CurrentTime);
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarkerForSetSongCurrentTime.End(); s_PreparePerfMarkerForSetSongCurrentTime.End();
#endif
MainObject.ScriptUpdate(CurrentTime, deltaTime, ScriptableObject.TickType.Update); MainObject.ScriptUpdate(CurrentTime, deltaTime, ScriptableObject.TickType.Update);
} }
if (IsMain == false) if (IsMain == false)
return; return;
#if UNITY_EDITOR || Using_ProfilerMarker
s_PreparePerfMarker.Begin(this); s_PreparePerfMarker.Begin(this);
#endif
#if UNITY_EDITOR #if UNITY_EDITOR
if (Keyboard.current[Key.LeftShift].isPressed) if (Keyboard.current[Key.LeftShift].isPressed)
#else #else
@@ -348,7 +356,9 @@ namespace Demo.Game
} }
} }
} }
#if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.End(); s_PreparePerfMarker.End();
#endif
} }
public IEnumerator GameExit() public IEnumerator GameExit()

View File

@@ -642,12 +642,16 @@ namespace Demo
/// </summary> /// </summary>
public partial class ScriptableObject public partial class ScriptableObject
{ {
private bool isEnableScript = false; private bool isEnableScript = false;
public string SourcePath = "";
public string ScriptName = "";
public string ScriptPath;
public string ScriptTypename;
public void EnableScript(string sourcePath, string scriptPath, string scriptType, ScriptableObject parent) public void EnableScript(string sourcePath, string scriptPath, string scriptType, ScriptableObject parent)
{ {
#if UNITY_EDITOR||true #if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker = new(ScriptName); s_PreparePerfMarker = new(ScriptName);
#endif #endif
if (isEnableScript) if (isEnableScript)
@@ -690,6 +694,15 @@ namespace Demo
} }
} }
/// <summary>
/// 脚本解析与Update执行
/// </summary>
public partial class ScriptableObject
{
}
/// <summary> /// <summary>
/// <para>使用<see cref="ScriptableCallAttribute"/>标记可编辑脚本所能够调用的函数,并附加注释</para> /// <para>使用<see cref="ScriptableCallAttribute"/>标记可编辑脚本所能够调用的函数,并附加注释</para>
/// <para>使用<see cref="DefaultScriptAttribute"/>标记派生类,并附加默认模板</para> /// <para>使用<see cref="DefaultScriptAttribute"/>标记派生类,并附加默认模板</para>
@@ -700,12 +713,7 @@ namespace Demo
public static Dictionary<string, Type> FastScriptableObjectTypen = new(); public static Dictionary<string, Type> FastScriptableObjectTypen = new();
public static bool IsAutoPlay = false; public static bool IsAutoPlay = false;
public string SourcePath = ""; #if UNITY_EDITOR||Using_ProfilerMarker
public string ScriptName = "";
public string ScriptPath;
public string ScriptTypename;
#if UNITY_EDITOR||true
public ProfilerMarker s_PreparePerfMarker; public ProfilerMarker s_PreparePerfMarker;
#endif #endif
public ScriptableObject Parent; public ScriptableObject Parent;
@@ -861,7 +869,7 @@ namespace Demo
return DoLoadSubScriptAsync(type, path, null); return DoLoadSubScriptAsync(type, path, null);
} }
/*
/// <summary> /// <summary>
/// 异步加载子脚本 /// 异步加载子脚本
/// </summary> /// </summary>
@@ -878,6 +886,7 @@ namespace Demo
{ {
StartCoroutine(DoLoadSubScriptAsync(type, path, null)); StartCoroutine(DoLoadSubScriptAsync(type, path, null));
} }
*/
private enum ParseStats private enum ParseStats
{ {
@@ -1147,7 +1156,7 @@ namespace Demo
return; return;
if (gameObject.activeInHierarchy == false) if (gameObject.activeInHierarchy == false)
return; return;
#if UNITY_EDITOR||true #if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.Begin(this); s_PreparePerfMarker.Begin(this);
#endif #endif
if (tickType == TickType.Reset) if (tickType == TickType.Reset)
@@ -1166,7 +1175,7 @@ namespace Demo
{ {
child.ScriptUpdate(currentTime, deltaTime, tickType); child.ScriptUpdate(currentTime, deltaTime, tickType);
} }
#if UNITY_EDITOR||true #if UNITY_EDITOR||Using_ProfilerMarker
s_PreparePerfMarker.End(); s_PreparePerfMarker.End();
#endif #endif
} }

View File

@@ -960,7 +960,7 @@ PlayerSettings:
QNX: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING QNX: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING
Server: UNITY_VISUAL_SCRIPTING Server: UNITY_VISUAL_SCRIPTING
Stadia: UNITY_POST_PROCESSING_STACK_V2 Stadia: UNITY_POST_PROCESSING_STACK_V2
Standalone: ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;PLATFORM_WINDOWS;DREAMTECK_SPLINES;UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING Standalone: ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;PLATFORM_WINDOWS;DREAMTECK_SPLINES;UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING;ENABLE_CLASS_Interaction
VisionOS: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING VisionOS: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING
WebGL: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING;DREAMTECK_SPLINES;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1 WebGL: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING;DREAMTECK_SPLINES;ODIN_VALIDATOR;ODIN_VALIDATOR_3_1;ODIN_INSPECTOR;ODIN_INSPECTOR_3;ODIN_INSPECTOR_3_1
Windows Store Apps: UNITY_VISUAL_SCRIPTING Windows Store Apps: UNITY_VISUAL_SCRIPTING