重构前夕

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

View File

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

View File

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

View File

@@ -960,7 +960,7 @@ PlayerSettings:
QNX: UNITY_POST_PROCESSING_STACK_V2;UNITY_VISUAL_SCRIPTING
Server: UNITY_VISUAL_SCRIPTING
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
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