mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
TProfile
TProfile
This commit is contained in:
@@ -5,7 +5,7 @@ namespace TEngine.Editor
|
|||||||
public class ProfilerDefineSymbols
|
public class ProfilerDefineSymbols
|
||||||
{
|
{
|
||||||
private const string EnableFirstProfiler = "FIRST_PROFILER";
|
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[]
|
private static readonly string[] AllProfilerDefineSymbols = new string[]
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ namespace TEngine.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁用所有日志脚本宏定义。
|
/// 禁用所有日志脚本宏定义。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MenuItem("TEngine/Profiler Define Symbols/Disable All Logs", false, 30)]
|
[MenuItem("TEngine/Profiler Define Symbols/Disable All Profiler", false, 30)]
|
||||||
public static void DisableAllLogs()
|
public static void DisableAllLogs()
|
||||||
{
|
{
|
||||||
foreach (string aboveLogScriptingDefineSymbol in AllProfilerDefineSymbols)
|
foreach (string aboveLogScriptingDefineSymbol in AllProfilerDefineSymbols)
|
||||||
@@ -28,7 +28,7 @@ namespace TEngine.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开启所有日志脚本宏定义。
|
/// 开启所有日志脚本宏定义。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MenuItem("TEngine/Profiler Define Symbols/Enable All Logs", false, 31)]
|
[MenuItem("TEngine/Profiler Define Symbols/Enable All Profiler", false, 31)]
|
||||||
public static void EnableAllLogs()
|
public static void EnableAllLogs()
|
||||||
{
|
{
|
||||||
DisableAllLogs();
|
DisableAllLogs();
|
||||||
|
3
Assets/TEngine/Runtime/GameFramework/ProFiler.meta
Normal file
3
Assets/TEngine/Runtime/GameFramework/ProFiler.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b759e5ec06e84c9d983e71fec5364815
|
||||||
|
timeCreated: 1681129900
|
67
Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs
Normal file
67
Assets/TEngine/Runtime/GameFramework/ProFiler/TProfiler.cs
Normal file
@@ -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--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f853bc680f948e5aa02d3e47e96a44b
|
||||||
|
timeCreated: 1681129934
|
@@ -1,5 +1,8 @@
|
|||||||
namespace TEngine
|
namespace TEngine
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UI行为接口。
|
||||||
|
/// </summary>
|
||||||
public interface IUIBehaviour
|
public interface IUIBehaviour
|
||||||
{
|
{
|
||||||
void ScriptGenerator();
|
void ScriptGenerator();
|
||||||
|
@@ -41,6 +41,11 @@ namespace TEngine
|
|||||||
/// UI父节点。
|
/// UI父节点。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UIBase Parent => parent;
|
public UIBase Parent => parent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动逸数据集。
|
||||||
|
/// </summary>
|
||||||
|
protected System.Object[] userDatas;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗口的实例资源对象。
|
/// 窗口的实例资源对象。
|
||||||
|
@@ -11,8 +11,6 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
private System.Action<UIWindow> _prepareCallback;
|
private System.Action<UIWindow> _prepareCallback;
|
||||||
|
|
||||||
private System.Object[] _userDatas;
|
|
||||||
|
|
||||||
private bool _isCreate = false;
|
private bool _isCreate = false;
|
||||||
|
|
||||||
private GameObject _panel;
|
private GameObject _panel;
|
||||||
@@ -64,9 +62,9 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_userDatas != null && _userDatas.Length >= 1)
|
if (userDatas != null && userDatas.Length >= 1)
|
||||||
{
|
{
|
||||||
return _userDatas[0];
|
return userDatas[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -78,7 +76,7 @@ namespace TEngine
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义数据集。
|
/// 自定义数据集。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public System.Object[] UserDatas => _userDatas;
|
public System.Object[] UserDatas => userDatas;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗口深度值
|
/// 窗口深度值
|
||||||
@@ -219,7 +217,7 @@ namespace TEngine
|
|||||||
|
|
||||||
internal void TryInvoke(System.Action<UIWindow> prepareCallback, System.Object[] userDatas)
|
internal void TryInvoke(System.Action<UIWindow> prepareCallback, System.Object[] userDatas)
|
||||||
{
|
{
|
||||||
_userDatas = userDatas;
|
base.userDatas = userDatas;
|
||||||
if (IsPrepare)
|
if (IsPrepare)
|
||||||
{
|
{
|
||||||
prepareCallback?.Invoke(this);
|
prepareCallback?.Invoke(this);
|
||||||
@@ -238,7 +236,7 @@ namespace TEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
_prepareCallback = prepareCallback;
|
_prepareCallback = prepareCallback;
|
||||||
_userDatas = userDatas;
|
base.userDatas = userDatas;
|
||||||
Handle = YooAssets.LoadAssetAsync<GameObject>(location);
|
Handle = YooAssets.LoadAssetAsync<GameObject>(location);
|
||||||
Handle.Completed += Handle_Completed;
|
Handle.Completed += Handle_Completed;
|
||||||
}
|
}
|
||||||
@@ -296,9 +294,9 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
var uiWidget = listChild[i];
|
var uiWidget = listChild[i];
|
||||||
|
|
||||||
UnityEngine.Profiling.Profiler.BeginSample(uiWidget.name);
|
TProfiler.BeginSample(uiWidget.name);
|
||||||
var needValid = uiWidget.InternalUpdate();
|
var needValid = uiWidget.InternalUpdate();
|
||||||
UnityEngine.Profiling.Profiler.EndSample();
|
TProfiler.EndSample();
|
||||||
|
|
||||||
if (!updateListValid && needValid)
|
if (!updateListValid && needValid)
|
||||||
{
|
{
|
||||||
@@ -312,7 +310,7 @@ namespace TEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnityEngine.Profiling.Profiler.BeginSample("OnUpdate");
|
TProfiler.BeginSample("OnUpdate");
|
||||||
|
|
||||||
bool needUpdate = false;
|
bool needUpdate = false;
|
||||||
if (listNextUpdateChild == null || listNextUpdateChild.Count <= 0)
|
if (listNextUpdateChild == null || listNextUpdateChild.Count <= 0)
|
||||||
@@ -326,7 +324,7 @@ namespace TEngine
|
|||||||
OnUpdate();
|
OnUpdate();
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
UnityEngine.Profiling.Profiler.EndSample();
|
TProfiler.EndSample();
|
||||||
|
|
||||||
return needUpdate;
|
return needUpdate;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user