diff --git a/Assets/TEngine/Editor/Utility/ProfilerDefineSymbols.cs b/Assets/TEngine/Editor/Utility/ProfilerDefineSymbols.cs
index 676e7a13..3c46cf7a 100644
--- a/Assets/TEngine/Editor/Utility/ProfilerDefineSymbols.cs
+++ b/Assets/TEngine/Editor/Utility/ProfilerDefineSymbols.cs
@@ -5,7 +5,7 @@ namespace TEngine.Editor
public class ProfilerDefineSymbols
{
private const string EnableFirstProfiler = "FIRST_PROFILER";
- private const string EnableDinProFiler = "DIN_PROFILER";
+ private const string EnableDinProFiler = "T_PROFILER";
private static readonly string[] AllProfilerDefineSymbols = new string[]
{
@@ -16,7 +16,7 @@ namespace TEngine.Editor
///
/// 禁用所有日志脚本宏定义。
///
- [MenuItem("TEngine/Profiler Define Symbols/Disable All Logs", false, 30)]
+ [MenuItem("TEngine/Profiler Define Symbols/Disable All Profiler", false, 30)]
public static void DisableAllLogs()
{
foreach (string aboveLogScriptingDefineSymbol in AllProfilerDefineSymbols)
@@ -28,7 +28,7 @@ namespace TEngine.Editor
///
/// 开启所有日志脚本宏定义。
///
- [MenuItem("TEngine/Profiler Define Symbols/Enable All Logs", false, 31)]
+ [MenuItem("TEngine/Profiler Define Symbols/Enable All Profiler", false, 31)]
public static void EnableAllLogs()
{
DisableAllLogs();
diff --git a/Assets/TEngine/Runtime/GameFramework/ProFiler.meta b/Assets/TEngine/Runtime/GameFramework/ProFiler.meta
new file mode 100644
index 00000000..a0fd7469
--- /dev/null
+++ b/Assets/TEngine/Runtime/GameFramework/ProFiler.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: b759e5ec06e84c9d983e71fec5364815
+timeCreated: 1681129900
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs b/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs
new file mode 100644
index 00000000..4862159f
--- /dev/null
+++ b/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs
@@ -0,0 +1,67 @@
+using System.Diagnostics;
+using UnityEngine.Profiling;
+
+namespace TEngine
+{
+ class TProfiler
+ {
+ private static int m_profileLevel = -1;
+ private static int m_currLevel = 0;
+ private static int m_sampleLevel = 0;
+
+ public static void SetProfileLevel(int level)
+ {
+ m_profileLevel = level;
+ }
+
+ [Conditional("FIRST_PROFILER")]
+ public static void BeginFirstSample(string name)
+ {
+ m_currLevel++;
+ if (m_profileLevel >= 0 && m_currLevel > m_profileLevel)
+ {
+ return;
+ }
+
+ m_sampleLevel++;
+ Profiler.BeginSample(name);
+ }
+
+ [Conditional("FIRST_PROFILER")]
+ public static void EndFirstSample()
+ {
+ if (m_currLevel <= m_sampleLevel)
+ {
+ Profiler.EndSample();
+ m_sampleLevel--;
+ }
+
+ m_currLevel--;
+ }
+
+ [Conditional("T_PROFILER")]
+ public static void BeginSample(string name)
+ {
+ m_currLevel++;
+ if (m_profileLevel >= 0 && m_currLevel > m_profileLevel)
+ {
+ return;
+ }
+
+ m_sampleLevel++;
+ Profiler.BeginSample(name);
+ }
+
+ [Conditional("T_PROFILER")]
+ public static void EndSample()
+ {
+ if (m_currLevel <= m_sampleLevel)
+ {
+ Profiler.EndSample();
+ m_sampleLevel--;
+ }
+
+ m_currLevel--;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs.meta b/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs.meta
new file mode 100644
index 00000000..925806ff
--- /dev/null
+++ b/Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9f853bc680f948e5aa02d3e47e96a44b
+timeCreated: 1681129934
\ No newline at end of file
diff --git a/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs
index 7a5ce16b..12a61c2f 100644
--- a/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs
+++ b/Assets/TEngine/Runtime/GameFramework/UI/IUIBehaviour.cs
@@ -1,5 +1,8 @@
namespace TEngine
{
+ ///
+ /// UI行为接口。
+ ///
public interface IUIBehaviour
{
void ScriptGenerator();
diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs
index a69fab6c..ef55c530 100644
--- a/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs
+++ b/Assets/TEngine/Runtime/GameFramework/UI/UIBase.cs
@@ -41,6 +41,11 @@ namespace TEngine
/// UI父节点。
///
public UIBase Parent => parent;
+
+ ///
+ /// 自动逸数据集。
+ ///
+ protected System.Object[] userDatas;
///
/// 窗口的实例资源对象。
diff --git a/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs
index 2e7dc899..a5929551 100644
--- a/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs
+++ b/Assets/TEngine/Runtime/GameFramework/UI/UIWindow.cs
@@ -11,8 +11,6 @@ namespace TEngine
{
private System.Action _prepareCallback;
- private System.Object[] _userDatas;
-
private bool _isCreate = false;
private GameObject _panel;
@@ -64,9 +62,9 @@ namespace TEngine
{
get
{
- if (_userDatas != null && _userDatas.Length >= 1)
+ if (userDatas != null && userDatas.Length >= 1)
{
- return _userDatas[0];
+ return userDatas[0];
}
else
{
@@ -78,7 +76,7 @@ namespace TEngine
///
/// 自定义数据集。
///
- public System.Object[] UserDatas => _userDatas;
+ public System.Object[] UserDatas => userDatas;
///
/// 窗口深度值
@@ -219,7 +217,7 @@ namespace TEngine
internal void TryInvoke(System.Action prepareCallback, System.Object[] userDatas)
{
- _userDatas = userDatas;
+ base.userDatas = userDatas;
if (IsPrepare)
{
prepareCallback?.Invoke(this);
@@ -238,7 +236,7 @@ namespace TEngine
}
_prepareCallback = prepareCallback;
- _userDatas = userDatas;
+ base.userDatas = userDatas;
Handle = YooAssets.LoadAssetAsync(location);
Handle.Completed += Handle_Completed;
}
@@ -296,9 +294,9 @@ namespace TEngine
{
var uiWidget = listChild[i];
- UnityEngine.Profiling.Profiler.BeginSample(uiWidget.name);
+ TProfiler.BeginSample(uiWidget.name);
var needValid = uiWidget.InternalUpdate();
- UnityEngine.Profiling.Profiler.EndSample();
+ TProfiler.EndSample();
if (!updateListValid && needValid)
{
@@ -312,7 +310,7 @@ namespace TEngine
}
}
- UnityEngine.Profiling.Profiler.BeginSample("OnUpdate");
+ TProfiler.BeginSample("OnUpdate");
bool needUpdate = false;
if (listNextUpdateChild == null || listNextUpdateChild.Count <= 0)
@@ -326,7 +324,7 @@ namespace TEngine
OnUpdate();
needUpdate = true;
}
- UnityEngine.Profiling.Profiler.EndSample();
+ TProfiler.EndSample();
return needUpdate;
}