统一命名规范private变量_filedInfo

This commit is contained in:
Alex-Rachel
2025-03-08 19:44:06 +08:00
parent 9b72cbcb7c
commit 6cf5aa46c1
67 changed files with 1093 additions and 1170 deletions

View File

@@ -37,7 +37,7 @@ namespace GameLogic
/// </summary>
public class UIResourceLoader : IUIResourceLoader
{
private readonly IResourceModule m_ResourceLoaderImp = ModuleSystem.GetModule<IResourceModule>();
private readonly IResourceModule _resourceLoaderImp = ModuleSystem.GetModule<IResourceModule>();
/// <summary>
/// 同步加载游戏物体并实例化。
@@ -49,7 +49,7 @@ namespace GameLogic
/// <remarks>会实例化资源到场景无需主动UnloadAssetDestroy时自动UnloadAsset。</remarks>
public GameObject LoadGameObject(string location, Transform parent = null, string packageName = "")
{
return m_ResourceLoaderImp.LoadGameObject(location, parent, packageName);
return _resourceLoaderImp.LoadGameObject(location, parent, packageName);
}
/// <summary>
@@ -63,7 +63,7 @@ namespace GameLogic
/// <remarks>会实例化资源到场景无需主动UnloadAssetDestroy时自动UnloadAsset。</remarks>
public async UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent = null, CancellationToken cancellationToken = default, string packageName = "")
{
return await m_ResourceLoaderImp.LoadGameObjectAsync(location, parent, cancellationToken, packageName);
return await _resourceLoaderImp.LoadGameObjectAsync(location, parent, cancellationToken, packageName);
}
}
}

View File

@@ -103,12 +103,12 @@ namespace GameLogic
/// <summary>
/// 存在Update更新的UI子组件列表。
/// </summary>
protected List<UIWidget> m_listUpdateChild = null;
protected List<UIWidget> ListUpdateChild = null;
/// <summary>
/// 是否持有Update行为。
/// </summary>
protected bool m_updateListValid = false;
protected bool UpdateListValid = false;
/// <summary>
/// 代码自动生成绑定。
@@ -186,7 +186,7 @@ namespace GameLogic
internal void SetUpdateDirty()
{
m_updateListValid = false;
UpdateListValid = false;
if (Parent != null)
{
Parent.SetUpdateDirty();

View File

@@ -10,30 +10,30 @@ namespace GameLogic
{
public sealed partial class UIModule : Singleton<UIModule>, IUpdate
{
private static Transform m_InstanceRoot = null;
private static Transform _instanceRoot = null;
private bool m_enableErrorLog = true;
private bool _enableErrorLog = true;
private Camera m_UICamera = null;
private readonly Camera _uiCamera = null;
private readonly List<UIWindow> _stack = new List<UIWindow>(100);
private readonly List<UIWindow> _uiStack = new List<UIWindow>(100);
public const int LAYER_DEEP = 2000;
public const int WINDOW_DEEP = 100;
public const int WINDOW_HIDE_LAYER = 2; // Ignore Raycast
public const int WINDOW_SHOW_LAYER = 5; // UI
public const int LayerDeep = 2000;
public const int WindowDeep = 100;
public const int WindowHideLayer = 2; // Ignore Raycast
public const int WindowShowLayer = 5; // UI
public static IUIResourceLoader Resource;
/// <summary>
/// UI根节点。
/// </summary>
public static Transform UIRoot => m_InstanceRoot;
public static Transform UIRoot => _instanceRoot;
/// <summary>
/// UI根节点。
/// </summary>
public Camera UICamera => m_UICamera;
public Camera UICamera => _uiCamera;
private ErrorLogger _errorLogger;
@@ -42,7 +42,7 @@ namespace GameLogic
var uiRoot = GameObject.Find("UIRoot");
if (uiRoot != null)
{
m_InstanceRoot = uiRoot.GetComponentInChildren<Canvas>()?.transform;
_instanceRoot = uiRoot.GetComponentInChildren<Canvas>()?.transform;
}
else
{
@@ -52,31 +52,31 @@ namespace GameLogic
Resource = new UIResourceLoader();
UnityEngine.Object.DontDestroyOnLoad(m_InstanceRoot.parent != null ? m_InstanceRoot.parent : m_InstanceRoot);
UnityEngine.Object.DontDestroyOnLoad(_instanceRoot.parent != null ? _instanceRoot.parent : _instanceRoot);
m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");
_instanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");
if (Debugger.Instance != null)
{
switch (Debugger.Instance.ActiveWindowType)
{
case DebuggerActiveWindowType.AlwaysOpen:
m_enableErrorLog = true;
_enableErrorLog = true;
break;
case DebuggerActiveWindowType.OnlyOpenWhenDevelopment:
m_enableErrorLog = Debug.isDebugBuild;
_enableErrorLog = Debug.isDebugBuild;
break;
case DebuggerActiveWindowType.OnlyOpenInEditor:
m_enableErrorLog = Application.isEditor;
_enableErrorLog = Application.isEditor;
break;
default:
m_enableErrorLog = false;
_enableErrorLog = false;
break;
}
if (m_enableErrorLog)
if (_enableErrorLog)
{
_errorLogger = new ErrorLogger(this);
}
@@ -91,9 +91,9 @@ namespace GameLogic
_errorLogger = null;
}
CloseAll(isShutDown:true);
if (m_InstanceRoot != null && m_InstanceRoot.parent != null)
if (_instanceRoot != null && _instanceRoot.parent != null)
{
UnityEngine.Object.Destroy(m_InstanceRoot.parent.gameObject);
UnityEngine.Object.Destroy(_instanceRoot.parent.gameObject);
}
}
@@ -164,12 +164,12 @@ namespace GameLogic
/// </summary>
public string GetTopWindow()
{
if (_stack.Count == 0)
if (_uiStack.Count == 0)
{
return string.Empty;
}
UIWindow topWindow = _stack[^1];
UIWindow topWindow = _uiStack[^1];
return topWindow.WindowName;
}
@@ -179,10 +179,10 @@ namespace GameLogic
public string GetTopWindow(int layer)
{
UIWindow lastOne = null;
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
if (_stack[i].WindowLayer == layer)
lastOne = _stack[i];
if (_uiStack[i].WindowLayer == layer)
lastOne = _uiStack[i];
}
if (lastOne == null)
@@ -196,9 +196,9 @@ namespace GameLogic
/// </summary>
public bool IsAnyLoading()
{
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
var window = _stack[i];
var window = _uiStack[i];
if (window.IsLoadDone == false)
return true;
}
@@ -390,13 +390,13 @@ namespace GameLogic
/// </summary>
public void CloseAll(bool isShutDown = false)
{
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
window.InternalDestroy(isShutDown);
}
_stack.Clear();
_uiStack.Clear();
}
/// <summary>
@@ -404,16 +404,16 @@ namespace GameLogic
/// </summary>
public void CloseAllWithOut(UIWindow withOut)
{
for (int i = _stack.Count - 1; i >= 0; i--)
for (int i = _uiStack.Count - 1; i >= 0; i--)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
if (window == withOut)
{
continue;
}
window.InternalDestroy();
_stack.RemoveAt(i);
_uiStack.RemoveAt(i);
}
}
@@ -422,16 +422,16 @@ namespace GameLogic
/// </summary>
public void CloseAllWithOut<T>() where T : UIWindow
{
for (int i = _stack.Count - 1; i >= 0; i--)
for (int i = _uiStack.Count - 1; i >= 0; i--)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
if (window.GetType() == typeof(T))
{
continue;
}
window.InternalDestroy();
_stack.RemoveAt(i);
_uiStack.RemoveAt(i);
}
}
@@ -445,13 +445,13 @@ namespace GameLogic
private void OnSortWindowDepth(int layer)
{
int depth = layer * LAYER_DEEP;
for (int i = 0; i < _stack.Count; i++)
int depth = layer * LayerDeep;
for (int i = 0; i < _uiStack.Count; i++)
{
if (_stack[i].WindowLayer == layer)
if (_uiStack[i].WindowLayer == layer)
{
_stack[i].Depth = depth;
depth += WINDOW_DEEP;
_uiStack[i].Depth = depth;
depth += WindowDeep;
}
}
}
@@ -459,9 +459,9 @@ namespace GameLogic
private void OnSetWindowVisible()
{
bool isHideNext = false;
for (int i = _stack.Count - 1; i >= 0; i--)
for (int i = _uiStack.Count - 1; i >= 0; i--)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
if (isHideNext == false)
{
if (window.IsHide)
@@ -581,9 +581,9 @@ namespace GameLogic
private UIWindow GetWindow(string windowName)
{
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
if (window.WindowName == windowName)
{
return window;
@@ -595,9 +595,9 @@ namespace GameLogic
private bool IsContains(string windowName)
{
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
UIWindow window = _stack[i];
UIWindow window = _uiStack[i];
if (window.WindowName == windowName)
{
return true;
@@ -615,9 +615,9 @@ namespace GameLogic
// 获取插入到所属层级的位置
int insertIndex = -1;
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
if (window.WindowLayer == _stack[i].WindowLayer)
if (window.WindowLayer == _uiStack[i].WindowLayer)
{
insertIndex = i + 1;
}
@@ -626,9 +626,9 @@ namespace GameLogic
// 如果没有所属层级,找到相邻层级
if (insertIndex == -1)
{
for (int i = 0; i < _stack.Count; i++)
for (int i = 0; i < _uiStack.Count; i++)
{
if (window.WindowLayer > _stack[i].WindowLayer)
if (window.WindowLayer > _uiStack[i].WindowLayer)
{
insertIndex = i + 1;
}
@@ -642,31 +642,31 @@ namespace GameLogic
}
// 最后插入到堆栈
_stack.Insert(insertIndex, window);
_uiStack.Insert(insertIndex, window);
}
private void Pop(UIWindow window)
{
// 从堆栈里移除
_stack.Remove(window);
_uiStack.Remove(window);
}
public void OnUpdate()
{
if (_stack == null)
if (_uiStack == null)
{
return;
}
int count = _stack.Count;
for (int i = 0; i < _stack.Count; i++)
int count = _uiStack.Count;
for (int i = 0; i < _uiStack.Count; i++)
{
if (_stack.Count != count)
if (_uiStack.Count != count)
{
break;
}
var window = _stack[i];
var window = _uiStack[i];
window.InternalUpdate();
}
}

View File

@@ -78,15 +78,15 @@ namespace GameLogic
List<UIWidget> listNextUpdateChild = null;
if (ListChild != null && ListChild.Count > 0)
{
listNextUpdateChild = m_listUpdateChild;
var updateListValid = m_updateListValid;
listNextUpdateChild = ListUpdateChild;
var updateListValid = UpdateListValid;
List<UIWidget> listChild = null;
if (!updateListValid)
{
if (listNextUpdateChild == null)
{
listNextUpdateChild = new List<UIWidget>();
m_listUpdateChild = listNextUpdateChild;
ListUpdateChild = listNextUpdateChild;
}
else
{
@@ -119,7 +119,7 @@ namespace GameLogic
if (!updateListValid)
{
m_updateListValid = true;
UpdateListValid = true;
}
}
@@ -265,7 +265,7 @@ namespace GameLogic
for (var index = 0; index < listCanvas.Length; index++)
{
var childCanvas = listCanvas[index];
childCanvas.sortingOrder = parentCanvas.sortingOrder + childCanvas.sortingOrder % UIModule.WINDOW_DEEP;
childCanvas.sortingOrder = parentCanvas.sortingOrder + childCanvas.sortingOrder % UIModule.WindowDeep;
}
}
}

View File

@@ -138,7 +138,7 @@ namespace GameLogic
{
if (_canvas != null)
{
return _canvas.gameObject.layer == UIModule.WINDOW_SHOW_LAYER;
return _canvas.gameObject.layer == UIModule.WindowShowLayer;
}
else
{
@@ -150,7 +150,7 @@ namespace GameLogic
{
if (_canvas != null)
{
int setLayer = value ? UIModule.WINDOW_SHOW_LAYER : UIModule.WINDOW_HIDE_LAYER;
int setLayer = value ? UIModule.WindowShowLayer : UIModule.WindowHideLayer;
if (_canvas.gameObject.layer == setLayer)
return;
@@ -295,15 +295,15 @@ namespace GameLogic
List<UIWidget> listNextUpdateChild = null;
if (ListChild != null && ListChild.Count > 0)
{
listNextUpdateChild = m_listUpdateChild;
var updateListValid = m_updateListValid;
listNextUpdateChild = ListUpdateChild;
var updateListValid = UpdateListValid;
List<UIWidget> listChild = null;
if (!updateListValid)
{
if (listNextUpdateChild == null)
{
listNextUpdateChild = new List<UIWidget>();
m_listUpdateChild = listNextUpdateChild;
ListUpdateChild = listNextUpdateChild;
}
else
{
@@ -336,7 +336,7 @@ namespace GameLogic
if (!updateListValid)
{
m_updateListValid = true;
UpdateListValid = true;
}
}

View File

@@ -281,16 +281,16 @@ namespace GameLogic
#region
private static bool m_isInit = false;
private static bool _isInit = false;
private static void CheckInit()
{
if (m_isInit == true)
if (_isInit == true)
{
return;
}
m_isInit = true;
_isInit = true;
_updateDriver ??= ModuleSystem.GetModule<IUpdateDriver>();
_updateDriver.AddUpdateListener(OnUpdate);
@@ -304,12 +304,12 @@ namespace GameLogic
private static void DeInit()
{
if (m_isInit == false)
if (_isInit == false)
{
return;
}
m_isInit = false;
_isInit = false;
_updateDriver ??= ModuleSystem.GetModule<IUpdateDriver>();
_updateDriver.RemoveUpdateListener(OnUpdate);

View File

@@ -10,11 +10,6 @@ namespace Procedure
/// </summary>
public abstract bool UseNativeDialog { get; }
protected IResourceModule _resourceModule;
protected ProcedureBase()
{
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
}
protected readonly IResourceModule _resourceModule = ModuleSystem.GetModule<IResourceModule>();
}
}

View File

@@ -10,7 +10,7 @@ namespace Procedure
{
public class ProcedureInitResources : ProcedureBase
{
private bool m_InitResourcesComplete = false;
private bool _initResourcesComplete = false;
public override bool UseNativeDialog => true;
@@ -18,7 +18,7 @@ namespace Procedure
{
base.OnEnter(procedureOwner);
m_InitResourcesComplete = false;
_initResourcesComplete = false;
LauncherMgr.Show(UIDefine.UILoadUpdate, "初始化资源中...");
@@ -30,7 +30,7 @@ namespace Procedure
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
if (!m_InitResourcesComplete)
if (!_initResourcesComplete)
{
// 初始化资源未完成则继续等待
return;
@@ -74,7 +74,7 @@ namespace Procedure
yield break;
}
m_InitResourcesComplete = true;
_initResourcesComplete = true;
}
private void OnInitResourcesError(ProcedureOwner procedureOwner)

View File

@@ -18,106 +18,103 @@ namespace Procedure
/// </summary>
public class ProcedureLoadAssembly : ProcedureBase
{
private bool m_enableAddressable = true;
private bool _enableAddressable = true;
public override bool UseNativeDialog => true;
private int m_LoadAssetCount;
private int m_LoadMetadataAssetCount;
private int m_FailureAssetCount;
private int m_FailureMetadataAssetCount;
private bool m_LoadAssemblyComplete;
private bool m_LoadMetadataAssemblyComplete;
private bool m_LoadAssemblyWait;
#pragma warning disable CS0414
private bool m_LoadMetadataAssemblyWait;
#pragma warning restore CS0414
private Assembly m_MainLogicAssembly;
private List<Assembly> m_HotfixAssemblys;
private IFsm<IProcedureModule> m_procedureOwner;
private UpdateSetting m_Setting;
private int _loadAssetCount;
private int _loadMetadataAssetCount;
private int _failureAssetCount;
private int _failureMetadataAssetCount;
private bool _loadAssemblyComplete;
private bool _loadMetadataAssemblyComplete;
private bool _loadAssemblyWait;
private bool _loadMetadataAssemblyWait;
private Assembly _mainLogicAssembly;
private List<Assembly> _hotfixAssemblyList;
private IFsm<IProcedureModule> _procedureOwner;
private UpdateSetting _setting;
protected override void OnInit(IFsm<IProcedureModule> procedureOwner)
{
base.OnInit(procedureOwner);
m_Setting = Settings.UpdateSetting;
_setting = Settings.UpdateSetting;
}
protected override void OnEnter(IFsm<IProcedureModule> procedureOwner)
{
base.OnEnter(procedureOwner);
Log.Debug("HyBridCLR ProcedureLoadAssembly OnEnter");
m_procedureOwner = procedureOwner;
Log.Debug("HybridCLR ProcedureLoadAssembly OnEnter");
_procedureOwner = procedureOwner;
LoadAssembly().Forget();
}
private async UniTaskVoid LoadAssembly()
{
m_LoadAssemblyComplete = false;
m_HotfixAssemblys = new List<Assembly>();
_loadAssemblyComplete = false;
_hotfixAssemblyList = new List<Assembly>();
//AOT Assembly加载原始metadata
if (m_Setting.Enable)
if (_setting.Enable)
{
#if !UNITY_EDITOR
m_LoadMetadataAssemblyComplete = false;
_loadMetadataAssemblyComplete = false;
LoadMetadataForAOTAssembly();
#else
m_LoadMetadataAssemblyComplete = true;
_loadMetadataAssemblyComplete = true;
#endif
}
else
{
m_LoadMetadataAssemblyComplete = true;
_loadMetadataAssemblyComplete = true;
}
if (!m_Setting.Enable || _resourceModule.PlayMode == EPlayMode.EditorSimulateMode)
if (!_setting.Enable || _resourceModule.PlayMode == EPlayMode.EditorSimulateMode)
{
m_MainLogicAssembly = GetMainLogicAssembly();
_mainLogicAssembly = GetMainLogicAssembly();
}
else
{
if (m_Setting.Enable)
if (_setting.Enable)
{
foreach (string hotUpdateDllName in m_Setting.HotUpdateAssemblies)
foreach (string hotUpdateDllName in _setting.HotUpdateAssemblies)
{
var assetLocation = hotUpdateDllName;
if (!m_enableAddressable)
if (!_enableAddressable)
{
assetLocation = Utility.Path.GetRegularPath(
Path.Combine(
"Assets",
m_Setting.AssemblyTextAssetPath,
$"{hotUpdateDllName}{m_Setting.AssemblyTextAssetExtension}"));
_setting.AssemblyTextAssetPath,
$"{hotUpdateDllName}{_setting.AssemblyTextAssetExtension}"));
}
Log.Debug($"LoadAsset: [ {assetLocation} ]");
m_LoadAssetCount++;
_loadAssetCount++;
var result = await _resourceModule.LoadAssetAsync<TextAsset>(assetLocation);
LoadAssetSuccess(result);
}
m_LoadAssemblyWait = true;
_loadAssemblyWait = true;
}
else
{
m_MainLogicAssembly = GetMainLogicAssembly();
_mainLogicAssembly = GetMainLogicAssembly();
}
}
if (m_LoadAssetCount == 0)
if (_loadAssetCount == 0)
{
m_LoadAssemblyComplete = true;
_loadAssemblyComplete = true;
}
}
protected override void OnUpdate(IFsm<IProcedureModule> procedureOwner, float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
if (!m_LoadAssemblyComplete)
if (!_loadAssemblyComplete)
{
return;
}
if (!m_LoadMetadataAssemblyComplete)
if (!_loadMetadataAssemblyComplete)
{
return;
}
@@ -126,17 +123,17 @@ namespace Procedure
private void AllAssemblyLoadComplete()
{
ChangeState<ProcedureStartGame>(m_procedureOwner);
ChangeState<ProcedureStartGame>(_procedureOwner);
#if UNITY_EDITOR
m_MainLogicAssembly = GetMainLogicAssembly();
_mainLogicAssembly = GetMainLogicAssembly();
#endif
if (m_MainLogicAssembly == null)
if (_mainLogicAssembly == null)
{
Log.Fatal($"Main logic assembly missing.");
return;
}
var appType = m_MainLogicAssembly.GetType("GameApp");
var appType = _mainLogicAssembly.GetType("GameApp");
if (appType == null)
{
Log.Fatal($"Main logic type 'GameMain' missing.");
@@ -148,31 +145,31 @@ namespace Procedure
Log.Fatal($"Main logic entry method 'Entrance' missing.");
return;
}
object[] objects = new object[] { new object[] { m_HotfixAssemblys } };
object[] objects = new object[] { new object[] { _hotfixAssemblyList } };
entryMethod.Invoke(appType, objects);
}
private Assembly GetMainLogicAssembly()
{
m_HotfixAssemblys.Clear();
_hotfixAssemblyList.Clear();
Assembly mainLogicAssembly = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (string.Compare(m_Setting.LogicMainDllName, $"{assembly.GetName().Name}.dll",
if (string.Compare(_setting.LogicMainDllName, $"{assembly.GetName().Name}.dll",
StringComparison.Ordinal) == 0)
{
mainLogicAssembly = assembly;
}
foreach (var hotUpdateDllName in m_Setting.HotUpdateAssemblies)
foreach (var hotUpdateDllName in _setting.HotUpdateAssemblies)
{
if (hotUpdateDllName == $"{assembly.GetName().Name}.dll")
{
m_HotfixAssemblys.Add(assembly);
_hotfixAssemblyList.Add(assembly);
}
}
if (mainLogicAssembly != null && m_HotfixAssemblys.Count == m_Setting.HotUpdateAssemblies.Count)
if (mainLogicAssembly != null && _hotfixAssemblyList.Count == _setting.HotUpdateAssemblies.Count)
{
break;
}
@@ -187,7 +184,7 @@ namespace Procedure
/// <param name="textAsset">代码资产。</param>
private void LoadAssetSuccess(TextAsset textAsset)
{
m_LoadAssetCount--;
_loadAssetCount--;
if (textAsset == null)
{
Log.Warning($"Load Assembly failed.");
@@ -200,22 +197,22 @@ namespace Procedure
try
{
var assembly = Assembly.Load(textAsset.bytes);
if (string.Compare(m_Setting.LogicMainDllName, assetName, StringComparison.Ordinal) == 0)
if (string.Compare(_setting.LogicMainDllName, assetName, StringComparison.Ordinal) == 0)
{
m_MainLogicAssembly = assembly;
_mainLogicAssembly = assembly;
}
m_HotfixAssemblys.Add(assembly);
_hotfixAssemblyList.Add(assembly);
Log.Debug($"Assembly [ {assembly.GetName().Name} ] loaded");
}
catch (Exception e)
{
m_FailureAssetCount++;
_failureAssetCount++;
Log.Fatal(e);
throw;
}
finally
{
m_LoadAssemblyComplete = m_LoadAssemblyWait && 0 == m_LoadAssetCount;
_loadAssemblyComplete = _loadAssemblyWait && 0 == _loadAssetCount;
}
_resourceModule.UnloadAsset(textAsset);
}
@@ -231,29 +228,29 @@ namespace Procedure
// 注意补充元数据是给AOT dll补充元数据而不是给热更新dll补充元数据。
// 热更新dll不缺元数据不需要补充如果调用LoadMetadataForAOTAssembly会返回错误
if (m_Setting.AOTMetaAssemblies.Count == 0)
if (_setting.AOTMetaAssemblies.Count == 0)
{
m_LoadMetadataAssemblyComplete = true;
_loadMetadataAssemblyComplete = true;
return;
}
foreach (string aotDllName in m_Setting.AOTMetaAssemblies)
foreach (string aotDllName in _setting.AOTMetaAssemblies)
{
var assetLocation = aotDllName;
if (!m_enableAddressable)
if (!_enableAddressable)
{
assetLocation = Utility.Path.GetRegularPath(
Path.Combine(
"Assets",
m_Setting.AssemblyTextAssetPath,
$"{aotDllName}{m_Setting.AssemblyTextAssetExtension}"));
_setting.AssemblyTextAssetPath,
$"{aotDllName}{_setting.AssemblyTextAssetExtension}"));
}
Log.Debug($"LoadMetadataAsset: [ {assetLocation} ]");
m_LoadMetadataAssetCount++;
_loadMetadataAssetCount++;
_resourceModule.LoadAsset<TextAsset>(assetLocation, LoadMetadataAssetSuccess);
}
m_LoadMetadataAssemblyWait = true;
_loadMetadataAssemblyWait = true;
}
/// <summary>
@@ -262,7 +259,7 @@ namespace Procedure
/// <param name="textAsset">代码资产。</param>
private void LoadMetadataAssetSuccess(TextAsset textAsset)
{
m_LoadMetadataAssetCount--;
_loadMetadataAssetCount--;
if (null == textAsset)
{
Log.Debug($"LoadMetadataAssetSuccess:Load Metadata failed.");
@@ -283,13 +280,13 @@ namespace Procedure
}
catch (Exception e)
{
m_FailureMetadataAssetCount++;
_failureMetadataAssetCount++;
Log.Fatal(e.Message);
throw;
}
finally
{
m_LoadMetadataAssemblyComplete = m_LoadMetadataAssemblyWait && 0 == m_LoadMetadataAssetCount;
_loadMetadataAssemblyComplete = _loadMetadataAssemblyWait && 0 == _loadMetadataAssetCount;
}
_resourceModule.UnloadAsset(textAsset);
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2d267ef672bd9e54e81b5cae5eac09a3
guid: 56995850190b0cb43aaa2dde5e71890e
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ebf7360e04898ef44aa6de753faf3bfb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -207,6 +207,54 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1168036240
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1168036242}
- component: {fileID: 1168036241}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1168036241
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1168036240}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ed5bd2409ef34ad99ff913c2ee6ddf90, type: 3}
m_Name:
m_EditorClassIdentifier:
ShowAdvanced: 0
AdvancedSetting1: 0
HiddenWhenShown:
InversedLogicField: 0
--- !u!4 &1168036242
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1168036240}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2425705316520036048
PrefabInstance:
m_ObjectHideFlags: 0

View File

@@ -8,12 +8,12 @@ namespace TEngine.Editor.Inspector
[CustomEditor(typeof(ProcedureSetting))]
internal sealed class ProcedureSettingInspector : GameFrameworkInspector
{
private SerializedProperty m_AvailableProcedureTypeNames = null;
private SerializedProperty m_EntranceProcedureTypeName = null;
private SerializedProperty _availableProcedureTypeNames = null;
private SerializedProperty _entranceProcedureTypeName = null;
private string[] m_ProcedureTypeNames = null;
private List<string> m_CurrentAvailableProcedureTypeNames = null;
private int m_EntranceProcedureIndex = -1;
private string[] _procedureTypeNames = null;
private List<string> _currentAvailableProcedureTypeNames = null;
private int _entranceProcedureIndex = -1;
public override void OnInspectorGUI()
{
@@ -23,7 +23,7 @@ namespace TEngine.Editor.Inspector
ProcedureSetting t = (ProcedureSetting)target;
if (string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
if (string.IsNullOrEmpty(_entranceProcedureTypeName.stringValue))
{
EditorGUILayout.HelpBox("Entrance procedure is invalid.", MessageType.Error);
}
@@ -31,23 +31,23 @@ namespace TEngine.Editor.Inspector
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
{
GUILayout.Label("Available Procedures", EditorStyles.boldLabel);
if (m_ProcedureTypeNames.Length > 0)
if (_procedureTypeNames.Length > 0)
{
EditorGUILayout.BeginVertical("box");
{
foreach (string procedureTypeName in m_ProcedureTypeNames)
foreach (string procedureTypeName in _procedureTypeNames)
{
bool selected = m_CurrentAvailableProcedureTypeNames.Contains(procedureTypeName);
bool selected = _currentAvailableProcedureTypeNames.Contains(procedureTypeName);
if (selected != EditorGUILayout.ToggleLeft(procedureTypeName, selected))
{
if (!selected)
{
m_CurrentAvailableProcedureTypeNames.Add(procedureTypeName);
_currentAvailableProcedureTypeNames.Add(procedureTypeName);
WriteAvailableProcedureTypeNames();
}
else if (procedureTypeName != m_EntranceProcedureTypeName.stringValue)
else if (procedureTypeName != _entranceProcedureTypeName.stringValue)
{
m_CurrentAvailableProcedureTypeNames.Remove(procedureTypeName);
_currentAvailableProcedureTypeNames.Remove(procedureTypeName);
WriteAvailableProcedureTypeNames();
}
}
@@ -60,15 +60,15 @@ namespace TEngine.Editor.Inspector
EditorGUILayout.HelpBox("There is no available procedure.", MessageType.Warning);
}
if (m_CurrentAvailableProcedureTypeNames.Count > 0)
if (_currentAvailableProcedureTypeNames.Count > 0)
{
EditorGUILayout.Separator();
int selectedIndex = EditorGUILayout.Popup("Entrance Procedure", m_EntranceProcedureIndex, m_CurrentAvailableProcedureTypeNames.ToArray());
if (selectedIndex != m_EntranceProcedureIndex)
int selectedIndex = EditorGUILayout.Popup("Entrance Procedure", _entranceProcedureIndex, _currentAvailableProcedureTypeNames.ToArray());
if (selectedIndex != _entranceProcedureIndex)
{
m_EntranceProcedureIndex = selectedIndex;
m_EntranceProcedureTypeName.stringValue = m_CurrentAvailableProcedureTypeNames[selectedIndex];
_entranceProcedureIndex = selectedIndex;
_entranceProcedureTypeName.stringValue = _currentAvailableProcedureTypeNames[selectedIndex];
}
}
else
@@ -92,28 +92,28 @@ namespace TEngine.Editor.Inspector
private void OnEnable()
{
m_AvailableProcedureTypeNames = serializedObject.FindProperty("availableProcedureTypeNames");
m_EntranceProcedureTypeName = serializedObject.FindProperty("entranceProcedureTypeName");
_availableProcedureTypeNames = serializedObject.FindProperty("availableProcedureTypeNames");
_entranceProcedureTypeName = serializedObject.FindProperty("entranceProcedureTypeName");
RefreshTypeNames();
}
private void RefreshTypeNames()
{
m_ProcedureTypeNames = Type.GetRuntimeTypeNames(typeof(ProcedureBase));
_procedureTypeNames = Type.GetRuntimeTypeNames(typeof(ProcedureBase));
ReadAvailableProcedureTypeNames();
int oldCount = m_CurrentAvailableProcedureTypeNames.Count;
m_CurrentAvailableProcedureTypeNames = m_CurrentAvailableProcedureTypeNames.Where(x => m_ProcedureTypeNames.Contains(x)).ToList();
if (m_CurrentAvailableProcedureTypeNames.Count != oldCount)
int oldCount = _currentAvailableProcedureTypeNames.Count;
_currentAvailableProcedureTypeNames = _currentAvailableProcedureTypeNames.Where(x => _procedureTypeNames.Contains(x)).ToList();
if (_currentAvailableProcedureTypeNames.Count != oldCount)
{
WriteAvailableProcedureTypeNames();
}
else if (!string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
else if (!string.IsNullOrEmpty(_entranceProcedureTypeName.stringValue))
{
m_EntranceProcedureIndex = m_CurrentAvailableProcedureTypeNames.IndexOf(m_EntranceProcedureTypeName.stringValue);
if (m_EntranceProcedureIndex < 0)
_entranceProcedureIndex = _currentAvailableProcedureTypeNames.IndexOf(_entranceProcedureTypeName.stringValue);
if (_entranceProcedureIndex < 0)
{
m_EntranceProcedureTypeName.stringValue = null;
_entranceProcedureTypeName.stringValue = null;
}
}
@@ -122,36 +122,36 @@ namespace TEngine.Editor.Inspector
private void ReadAvailableProcedureTypeNames()
{
m_CurrentAvailableProcedureTypeNames = new List<string>();
int count = m_AvailableProcedureTypeNames.arraySize;
_currentAvailableProcedureTypeNames = new List<string>();
int count = _availableProcedureTypeNames.arraySize;
for (int i = 0; i < count; i++)
{
m_CurrentAvailableProcedureTypeNames.Add(m_AvailableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue);
_currentAvailableProcedureTypeNames.Add(_availableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue);
}
}
private void WriteAvailableProcedureTypeNames()
{
m_AvailableProcedureTypeNames.ClearArray();
if (m_CurrentAvailableProcedureTypeNames == null)
_availableProcedureTypeNames.ClearArray();
if (_currentAvailableProcedureTypeNames == null)
{
return;
}
m_CurrentAvailableProcedureTypeNames.Sort();
int count = m_CurrentAvailableProcedureTypeNames.Count;
_currentAvailableProcedureTypeNames.Sort();
int count = _currentAvailableProcedureTypeNames.Count;
for (int i = 0; i < count; i++)
{
m_AvailableProcedureTypeNames.InsertArrayElementAtIndex(i);
m_AvailableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue = m_CurrentAvailableProcedureTypeNames[i];
_availableProcedureTypeNames.InsertArrayElementAtIndex(i);
_availableProcedureTypeNames.GetArrayElementAtIndex(i).stringValue = _currentAvailableProcedureTypeNames[i];
}
if (!string.IsNullOrEmpty(m_EntranceProcedureTypeName.stringValue))
if (!string.IsNullOrEmpty(_entranceProcedureTypeName.stringValue))
{
m_EntranceProcedureIndex = m_CurrentAvailableProcedureTypeNames.IndexOf(m_EntranceProcedureTypeName.stringValue);
if (m_EntranceProcedureIndex < 0)
_entranceProcedureIndex = _currentAvailableProcedureTypeNames.IndexOf(_entranceProcedureTypeName.stringValue);
if (_entranceProcedureIndex < 0)
{
m_EntranceProcedureTypeName.stringValue = null;
_entranceProcedureTypeName.stringValue = null;
}
}
}

View File

@@ -16,23 +16,23 @@ namespace TEngine.Editor.Inspector
"WebPlayMode (WebGL运行模式)"
};
private SerializedProperty m_PlayMode = null;
private SerializedProperty m_UpdatableWhilePlaying = null;
private SerializedProperty m_Milliseconds = null;
private SerializedProperty m_MinUnloadUnusedAssetsInterval = null;
private SerializedProperty m_MaxUnloadUnusedAssetsInterval = null;
private SerializedProperty m_UseSystemUnloadUnusedAssets = null;
private SerializedProperty m_AssetAutoReleaseInterval = null;
private SerializedProperty m_AssetCapacity = null;
private SerializedProperty m_AssetExpireTime = null;
private SerializedProperty m_AssetPriority = null;
private SerializedProperty m_DownloadingMaxNum = null;
private SerializedProperty m_FailedTryAgain = null;
private SerializedProperty m_PackageName = null;
private int m_playModeIndex = 0;
private SerializedProperty _playMode = null;
private SerializedProperty _updatableWhilePlaying = null;
private SerializedProperty _milliseconds = null;
private SerializedProperty _minUnloadUnusedAssetsInterval = null;
private SerializedProperty _maxUnloadUnusedAssetsInterval = null;
private SerializedProperty _useSystemUnloadUnusedAssets = null;
private SerializedProperty _assetAutoReleaseInterval = null;
private SerializedProperty _assetCapacity = null;
private SerializedProperty _assetExpireTime = null;
private SerializedProperty _assetPriority = null;
private SerializedProperty _downloadingMaxNum = null;
private SerializedProperty _failedTryAgain = null;
private SerializedProperty _packageName = null;
private int _playModeIndex = 0;
private int m_PackageNameIndex = 0;
private string[] m_PackageNames;
private int _packageNameIndex = 0;
private string[] _packageNames;
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
@@ -49,48 +49,48 @@ namespace TEngine.Editor.Inspector
}
else
{
int selectedIndex = EditorGUILayout.Popup("Play Mode", m_playModeIndex, _playModeNames);
if (selectedIndex != m_playModeIndex)
int selectedIndex = EditorGUILayout.Popup("Play Mode", _playModeIndex, _playModeNames);
if (selectedIndex != _playModeIndex)
{
m_playModeIndex = selectedIndex;
m_PlayMode.enumValueIndex = selectedIndex;
_playModeIndex = selectedIndex;
_playMode.enumValueIndex = selectedIndex;
}
}
}
EditorGUILayout.PropertyField(m_UpdatableWhilePlaying);
EditorGUILayout.PropertyField(_updatableWhilePlaying);
EditorGUI.EndDisabledGroup();
m_PackageNames = GetBuildPackageNames().ToArray();
m_PackageNameIndex = Array.IndexOf(m_PackageNames, m_PackageName.stringValue);
if (m_PackageNameIndex < 0)
_packageNames = GetBuildPackageNames().ToArray();
_packageNameIndex = Array.IndexOf(_packageNames, _packageName.stringValue);
if (_packageNameIndex < 0)
{
m_PackageNameIndex = 0;
_packageNameIndex = 0;
}
m_PackageNameIndex = EditorGUILayout.Popup("Package Name", m_PackageNameIndex, m_PackageNames);
if (m_PackageName.stringValue != m_PackageNames[m_PackageNameIndex])
_packageNameIndex = EditorGUILayout.Popup("Package Name", _packageNameIndex, _packageNames);
if (_packageName.stringValue != _packageNames[_packageNameIndex])
{
m_PackageName.stringValue = m_PackageNames[m_PackageNameIndex];
_packageName.stringValue = _packageNames[_packageNameIndex];
}
int milliseconds = EditorGUILayout.DelayedIntField("Milliseconds", m_Milliseconds.intValue);
if (milliseconds != m_Milliseconds.intValue)
int milliseconds = EditorGUILayout.DelayedIntField("Milliseconds", _milliseconds.intValue);
if (milliseconds != _milliseconds.intValue)
{
if (EditorApplication.isPlaying)
{
t.Milliseconds = milliseconds;
t.milliseconds = milliseconds;
}
else
{
m_Milliseconds.longValue = milliseconds;
_milliseconds.longValue = milliseconds;
}
}
EditorGUILayout.PropertyField(m_UseSystemUnloadUnusedAssets);
EditorGUILayout.PropertyField(_useSystemUnloadUnusedAssets);
float minUnloadUnusedAssetsInterval =
EditorGUILayout.Slider("Min Unload Unused Assets Interval", m_MinUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
if (Math.Abs(minUnloadUnusedAssetsInterval - m_MinUnloadUnusedAssetsInterval.floatValue) > 0.01f)
EditorGUILayout.Slider("Min Unload Unused Assets Interval", _minUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
if (Math.Abs(minUnloadUnusedAssetsInterval - _minUnloadUnusedAssetsInterval.floatValue) > 0.01f)
{
if (EditorApplication.isPlaying)
{
@@ -98,13 +98,13 @@ namespace TEngine.Editor.Inspector
}
else
{
m_MinUnloadUnusedAssetsInterval.floatValue = minUnloadUnusedAssetsInterval;
_minUnloadUnusedAssetsInterval.floatValue = minUnloadUnusedAssetsInterval;
}
}
float maxUnloadUnusedAssetsInterval =
EditorGUILayout.Slider("Max Unload Unused Assets Interval", m_MaxUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
if (Math.Abs(maxUnloadUnusedAssetsInterval - m_MaxUnloadUnusedAssetsInterval.floatValue) > 0.01f)
EditorGUILayout.Slider("Max Unload Unused Assets Interval", _maxUnloadUnusedAssetsInterval.floatValue, 0f, 3600f);
if (Math.Abs(maxUnloadUnusedAssetsInterval - _maxUnloadUnusedAssetsInterval.floatValue) > 0.01f)
{
if (EditorApplication.isPlaying)
{
@@ -112,12 +112,12 @@ namespace TEngine.Editor.Inspector
}
else
{
m_MaxUnloadUnusedAssetsInterval.floatValue = maxUnloadUnusedAssetsInterval;
_maxUnloadUnusedAssetsInterval.floatValue = maxUnloadUnusedAssetsInterval;
}
}
float downloadingMaxNum = EditorGUILayout.Slider("Max Downloading Num", m_DownloadingMaxNum.intValue, 1f, 48f);
if (Math.Abs(downloadingMaxNum - m_DownloadingMaxNum.intValue) > 0.001f)
float downloadingMaxNum = EditorGUILayout.Slider("Max Downloading Num", _downloadingMaxNum.intValue, 1f, 48f);
if (Math.Abs(downloadingMaxNum - _downloadingMaxNum.intValue) > 0.001f)
{
if (EditorApplication.isPlaying)
{
@@ -125,12 +125,12 @@ namespace TEngine.Editor.Inspector
}
else
{
m_DownloadingMaxNum.intValue = (int)downloadingMaxNum;
_downloadingMaxNum.intValue = (int)downloadingMaxNum;
}
}
float failedTryAgain = EditorGUILayout.Slider("Max FailedTryAgain Count", m_FailedTryAgain.intValue, 1f, 48f);
if (Math.Abs(failedTryAgain - m_FailedTryAgain.intValue) > 0.001f)
float failedTryAgain = EditorGUILayout.Slider("Max FailedTryAgain Count", _failedTryAgain.intValue, 1f, 48f);
if (Math.Abs(failedTryAgain - _failedTryAgain.intValue) > 0.001f)
{
if (EditorApplication.isPlaying)
{
@@ -138,14 +138,14 @@ namespace TEngine.Editor.Inspector
}
else
{
m_FailedTryAgain.intValue = (int)failedTryAgain;
_failedTryAgain.intValue = (int)failedTryAgain;
}
}
EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying);
{
float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", m_AssetAutoReleaseInterval.floatValue);
if (Math.Abs(assetAutoReleaseInterval - m_AssetAutoReleaseInterval.floatValue) > 0.01f)
float assetAutoReleaseInterval = EditorGUILayout.DelayedFloatField("Asset Auto Release Interval", _assetAutoReleaseInterval.floatValue);
if (Math.Abs(assetAutoReleaseInterval - _assetAutoReleaseInterval.floatValue) > 0.01f)
{
if (EditorApplication.isPlaying)
{
@@ -153,12 +153,12 @@ namespace TEngine.Editor.Inspector
}
else
{
m_AssetAutoReleaseInterval.floatValue = assetAutoReleaseInterval;
_assetAutoReleaseInterval.floatValue = assetAutoReleaseInterval;
}
}
int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", m_AssetCapacity.intValue);
if (assetCapacity != m_AssetCapacity.intValue)
int assetCapacity = EditorGUILayout.DelayedIntField("Asset Capacity", _assetCapacity.intValue);
if (assetCapacity != _assetCapacity.intValue)
{
if (EditorApplication.isPlaying)
{
@@ -166,12 +166,12 @@ namespace TEngine.Editor.Inspector
}
else
{
m_AssetCapacity.intValue = assetCapacity;
_assetCapacity.intValue = assetCapacity;
}
}
float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", m_AssetExpireTime.floatValue);
if (Math.Abs(assetExpireTime - m_AssetExpireTime.floatValue) > 0.01f)
float assetExpireTime = EditorGUILayout.DelayedFloatField("Asset Expire Time", _assetExpireTime.floatValue);
if (Math.Abs(assetExpireTime - _assetExpireTime.floatValue) > 0.01f)
{
if (EditorApplication.isPlaying)
{
@@ -179,12 +179,12 @@ namespace TEngine.Editor.Inspector
}
else
{
m_AssetExpireTime.floatValue = assetExpireTime;
_assetExpireTime.floatValue = assetExpireTime;
}
}
int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", m_AssetPriority.intValue);
if (assetPriority != m_AssetPriority.intValue)
int assetPriority = EditorGUILayout.DelayedIntField("Asset Priority", _assetPriority.intValue);
if (assetPriority != _assetPriority.intValue)
{
if (EditorApplication.isPlaying)
{
@@ -192,7 +192,7 @@ namespace TEngine.Editor.Inspector
}
else
{
m_AssetPriority.intValue = assetPriority;
_assetPriority.intValue = assetPriority;
}
}
}
@@ -219,19 +219,19 @@ namespace TEngine.Editor.Inspector
private void OnEnable()
{
m_PlayMode = serializedObject.FindProperty("playMode");
m_UpdatableWhilePlaying = serializedObject.FindProperty("m_UpdatableWhilePlaying");
m_Milliseconds = serializedObject.FindProperty("Milliseconds");
m_MinUnloadUnusedAssetsInterval = serializedObject.FindProperty("m_MinUnloadUnusedAssetsInterval");
m_MaxUnloadUnusedAssetsInterval = serializedObject.FindProperty("m_MaxUnloadUnusedAssetsInterval");
m_UseSystemUnloadUnusedAssets = serializedObject.FindProperty("m_UseSystemUnloadUnusedAssets");
m_AssetAutoReleaseInterval = serializedObject.FindProperty("m_AssetAutoReleaseInterval");
m_AssetCapacity = serializedObject.FindProperty("m_AssetCapacity");
m_AssetExpireTime = serializedObject.FindProperty("m_AssetExpireTime");
m_AssetPriority = serializedObject.FindProperty("m_AssetPriority");
m_DownloadingMaxNum = serializedObject.FindProperty("m_DownloadingMaxNum");
m_FailedTryAgain = serializedObject.FindProperty("m_FailedTryAgain");
m_PackageName = serializedObject.FindProperty("packageName");
_playMode = serializedObject.FindProperty("playMode");
_updatableWhilePlaying = serializedObject.FindProperty("updatableWhilePlaying");
_milliseconds = serializedObject.FindProperty("milliseconds");
_minUnloadUnusedAssetsInterval = serializedObject.FindProperty("minUnloadUnusedAssetsInterval");
_maxUnloadUnusedAssetsInterval = serializedObject.FindProperty("maxUnloadUnusedAssetsInterval");
_useSystemUnloadUnusedAssets = serializedObject.FindProperty("useSystemUnloadUnusedAssets");
_assetAutoReleaseInterval = serializedObject.FindProperty("assetAutoReleaseInterval");
_assetCapacity = serializedObject.FindProperty("assetCapacity");
_assetExpireTime = serializedObject.FindProperty("assetExpireTime");
_assetPriority = serializedObject.FindProperty("assetPriority");
_downloadingMaxNum = serializedObject.FindProperty("downloadingMaxNum");
_failedTryAgain = serializedObject.FindProperty("failedTryAgain");
_packageName = serializedObject.FindProperty("packageName");
RefreshModes();
RefreshTypeNames();
@@ -239,7 +239,7 @@ namespace TEngine.Editor.Inspector
private void RefreshModes()
{
m_playModeIndex = m_PlayMode.enumValueIndex > 0 ? m_PlayMode.enumValueIndex : 0;
_playModeIndex = _playMode.enumValueIndex > 0 ? _playMode.enumValueIndex : 0;
}
private void RefreshTypeNames()

View File

@@ -14,21 +14,21 @@ namespace TEngine.Editor
private static readonly float[] GameSpeed = new float[] { 0f, 0.01f, 0.1f, 0.25f, 0.5f, 1f, 1.5f, 2f, 4f, 8f };
private static readonly string[] GameSpeedForDisplay = new string[] { "0x", "0.01x", "0.1x", "0.25x", "0.5x", "1x", "1.5x", "2x", "4x", "8x" };
private SerializedProperty m_EditorLanguage = null;
private SerializedProperty m_TextHelperTypeName = null;
private SerializedProperty m_LogHelperTypeName = null;
private SerializedProperty m_JsonHelperTypeName = null;
private SerializedProperty m_FrameRate = null;
private SerializedProperty m_GameSpeed = null;
private SerializedProperty m_RunInBackground = null;
private SerializedProperty m_NeverSleep = null;
private SerializedProperty _editorLanguage = null;
private SerializedProperty _textHelperTypeName = null;
private SerializedProperty _logHelperTypeName = null;
private SerializedProperty _jsonHelperTypeName = null;
private SerializedProperty _frameRate = null;
private SerializedProperty _gameSpeed = null;
private SerializedProperty _runInBackground = null;
private SerializedProperty _neverSleep = null;
private string[] m_TextHelperTypeNames = null;
private int m_TextHelperTypeNameIndex = 0;
private string[] m_LogHelperTypeNames = null;
private int m_LogHelperTypeNameIndex = 0;
private string[] m_JsonHelperTypeNames = null;
private int m_JsonHelperTypeNameIndex = 0;
private string[] _textHelperTypeNames = null;
private int _textHelperTypeNameIndex = 0;
private string[] _logHelperTypeNames = null;
private int _logHelperTypeNameIndex = 0;
private string[] _jsonHelperTypeNames = null;
private int _jsonHelperTypeNameIndex = 0;
public override void OnInspectorGUI()
{
@@ -40,39 +40,39 @@ namespace TEngine.Editor
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
{
EditorGUILayout.PropertyField(m_EditorLanguage);
EditorGUILayout.PropertyField(_editorLanguage);
EditorGUILayout.BeginVertical("box");
{
EditorGUILayout.LabelField("Global Helpers", EditorStyles.boldLabel);
int textHelperSelectedIndex = EditorGUILayout.Popup("Text Helper", m_TextHelperTypeNameIndex, m_TextHelperTypeNames);
if (textHelperSelectedIndex != m_TextHelperTypeNameIndex)
int textHelperSelectedIndex = EditorGUILayout.Popup("Text Helper", _textHelperTypeNameIndex, _textHelperTypeNames);
if (textHelperSelectedIndex != _textHelperTypeNameIndex)
{
m_TextHelperTypeNameIndex = textHelperSelectedIndex;
m_TextHelperTypeName.stringValue = textHelperSelectedIndex <= 0 ? null : m_TextHelperTypeNames[textHelperSelectedIndex];
_textHelperTypeNameIndex = textHelperSelectedIndex;
_textHelperTypeName.stringValue = textHelperSelectedIndex <= 0 ? null : _textHelperTypeNames[textHelperSelectedIndex];
}
int logHelperSelectedIndex = EditorGUILayout.Popup("Log Helper", m_LogHelperTypeNameIndex, m_LogHelperTypeNames);
if (logHelperSelectedIndex != m_LogHelperTypeNameIndex)
int logHelperSelectedIndex = EditorGUILayout.Popup("Log Helper", _logHelperTypeNameIndex, _logHelperTypeNames);
if (logHelperSelectedIndex != _logHelperTypeNameIndex)
{
m_LogHelperTypeNameIndex = logHelperSelectedIndex;
m_LogHelperTypeName.stringValue = logHelperSelectedIndex <= 0 ? null : m_LogHelperTypeNames[logHelperSelectedIndex];
_logHelperTypeNameIndex = logHelperSelectedIndex;
_logHelperTypeName.stringValue = logHelperSelectedIndex <= 0 ? null : _logHelperTypeNames[logHelperSelectedIndex];
}
int jsonHelperSelectedIndex = EditorGUILayout.Popup("JSON Helper", m_JsonHelperTypeNameIndex, m_JsonHelperTypeNames);
if (jsonHelperSelectedIndex != m_JsonHelperTypeNameIndex)
int jsonHelperSelectedIndex = EditorGUILayout.Popup("JSON Helper", _jsonHelperTypeNameIndex, _jsonHelperTypeNames);
if (jsonHelperSelectedIndex != _jsonHelperTypeNameIndex)
{
m_JsonHelperTypeNameIndex = jsonHelperSelectedIndex;
m_JsonHelperTypeName.stringValue = jsonHelperSelectedIndex <= 0 ? null : m_JsonHelperTypeNames[jsonHelperSelectedIndex];
_jsonHelperTypeNameIndex = jsonHelperSelectedIndex;
_jsonHelperTypeName.stringValue = jsonHelperSelectedIndex <= 0 ? null : _jsonHelperTypeNames[jsonHelperSelectedIndex];
}
}
EditorGUILayout.EndVertical();
}
EditorGUI.EndDisabledGroup();
int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 120);
if (frameRate != m_FrameRate.intValue)
int frameRate = EditorGUILayout.IntSlider("Frame Rate", _frameRate.intValue, 1, 120);
if (frameRate != _frameRate.intValue)
{
if (EditorApplication.isPlaying)
{
@@ -80,20 +80,20 @@ namespace TEngine.Editor
}
else
{
m_FrameRate.intValue = frameRate;
_frameRate.intValue = frameRate;
}
}
EditorGUILayout.BeginVertical("box");
{
float gameSpeed = EditorGUILayout.Slider("Game Speed", m_GameSpeed.floatValue, 0f, 8f);
float gameSpeed = EditorGUILayout.Slider("Game Speed", _gameSpeed.floatValue, 0f, 8f);
int selectedGameSpeed = GUILayout.SelectionGrid(GetSelectedGameSpeed(gameSpeed), GameSpeedForDisplay, 5);
if (selectedGameSpeed >= 0)
{
gameSpeed = GetGameSpeed(selectedGameSpeed);
}
if (Math.Abs(gameSpeed - m_GameSpeed.floatValue) > 0.01f)
if (Math.Abs(gameSpeed - _gameSpeed.floatValue) > 0.01f)
{
if (EditorApplication.isPlaying)
{
@@ -101,14 +101,14 @@ namespace TEngine.Editor
}
else
{
m_GameSpeed.floatValue = gameSpeed;
_gameSpeed.floatValue = gameSpeed;
}
}
}
EditorGUILayout.EndVertical();
bool runInBackground = EditorGUILayout.Toggle("Run in Background", m_RunInBackground.boolValue);
if (runInBackground != m_RunInBackground.boolValue)
bool runInBackground = EditorGUILayout.Toggle("Run in Background", _runInBackground.boolValue);
if (runInBackground != _runInBackground.boolValue)
{
if (EditorApplication.isPlaying)
{
@@ -116,12 +116,12 @@ namespace TEngine.Editor
}
else
{
m_RunInBackground.boolValue = runInBackground;
_runInBackground.boolValue = runInBackground;
}
}
bool neverSleep = EditorGUILayout.Toggle("Never Sleep", m_NeverSleep.boolValue);
if (neverSleep != m_NeverSleep.boolValue)
bool neverSleep = EditorGUILayout.Toggle("Never Sleep", _neverSleep.boolValue);
if (neverSleep != _neverSleep.boolValue)
{
if (EditorApplication.isPlaying)
{
@@ -129,7 +129,7 @@ namespace TEngine.Editor
}
else
{
m_NeverSleep.boolValue = neverSleep;
_neverSleep.boolValue = neverSleep;
}
}
@@ -145,14 +145,14 @@ namespace TEngine.Editor
private void OnEnable()
{
m_EditorLanguage = serializedObject.FindProperty("m_EditorLanguage");
m_TextHelperTypeName = serializedObject.FindProperty("m_TextHelperTypeName");
m_LogHelperTypeName = serializedObject.FindProperty("m_LogHelperTypeName");
m_JsonHelperTypeName = serializedObject.FindProperty("m_JsonHelperTypeName");
m_FrameRate = serializedObject.FindProperty("m_FrameRate");
m_GameSpeed = serializedObject.FindProperty("m_GameSpeed");
m_RunInBackground = serializedObject.FindProperty("m_RunInBackground");
m_NeverSleep = serializedObject.FindProperty("m_NeverSleep");
_editorLanguage = serializedObject.FindProperty("editorLanguage");
_textHelperTypeName = serializedObject.FindProperty("textHelperTypeName");
_logHelperTypeName = serializedObject.FindProperty("logHelperTypeName");
_jsonHelperTypeName = serializedObject.FindProperty("jsonHelperTypeName");
_frameRate = serializedObject.FindProperty("frameRate");
_gameSpeed = serializedObject.FindProperty("gameSpeed");
_runInBackground = serializedObject.FindProperty("runInBackground");
_neverSleep = serializedObject.FindProperty("neverSleep");
RefreshTypeNames();
}
@@ -165,15 +165,15 @@ namespace TEngine.Editor
};
textHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(Utility.Text.ITextHelper)));
m_TextHelperTypeNames = textHelperTypeNames.ToArray();
m_TextHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_TextHelperTypeName.stringValue))
_textHelperTypeNames = textHelperTypeNames.ToArray();
_textHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(_textHelperTypeName.stringValue))
{
m_TextHelperTypeNameIndex = textHelperTypeNames.IndexOf(m_TextHelperTypeName.stringValue);
if (m_TextHelperTypeNameIndex <= 0)
_textHelperTypeNameIndex = textHelperTypeNames.IndexOf(_textHelperTypeName.stringValue);
if (_textHelperTypeNameIndex <= 0)
{
m_TextHelperTypeNameIndex = 0;
m_TextHelperTypeName.stringValue = null;
_textHelperTypeNameIndex = 0;
_textHelperTypeName.stringValue = null;
}
}
@@ -183,15 +183,15 @@ namespace TEngine.Editor
};
logHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(GameFrameworkLog.ILogHelper)));
m_LogHelperTypeNames = logHelperTypeNames.ToArray();
m_LogHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_LogHelperTypeName.stringValue))
_logHelperTypeNames = logHelperTypeNames.ToArray();
_logHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(_logHelperTypeName.stringValue))
{
m_LogHelperTypeNameIndex = logHelperTypeNames.IndexOf(m_LogHelperTypeName.stringValue);
if (m_LogHelperTypeNameIndex <= 0)
_logHelperTypeNameIndex = logHelperTypeNames.IndexOf(_logHelperTypeName.stringValue);
if (_logHelperTypeNameIndex <= 0)
{
m_LogHelperTypeNameIndex = 0;
m_LogHelperTypeName.stringValue = null;
_logHelperTypeNameIndex = 0;
_logHelperTypeName.stringValue = null;
}
}
@@ -201,15 +201,15 @@ namespace TEngine.Editor
};
jsonHelperTypeNames.AddRange(Type.GetRuntimeTypeNames(typeof(Utility.Json.IJsonHelper)));
m_JsonHelperTypeNames = jsonHelperTypeNames.ToArray();
m_JsonHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_JsonHelperTypeName.stringValue))
_jsonHelperTypeNames = jsonHelperTypeNames.ToArray();
_jsonHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(_jsonHelperTypeName.stringValue))
{
m_JsonHelperTypeNameIndex = jsonHelperTypeNames.IndexOf(m_JsonHelperTypeName.stringValue);
if (m_JsonHelperTypeNameIndex <= 0)
_jsonHelperTypeNameIndex = jsonHelperTypeNames.IndexOf(_jsonHelperTypeName.stringValue);
if (_jsonHelperTypeNameIndex <= 0)
{
m_JsonHelperTypeNameIndex = 0;
m_JsonHelperTypeName.stringValue = null;
_jsonHelperTypeNameIndex = 0;
_jsonHelperTypeName.stringValue = null;
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 07e683cdfed9cae409efdc29179643ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -341,7 +341,7 @@ namespace TEngine
[StructLayout(LayoutKind.Auto)]
public struct Enumerator : IEnumerator<T>, IEnumerator
{
private LinkedList<T>.Enumerator m_Enumerator;
private LinkedList<T>.Enumerator _enumerator;
internal Enumerator(LinkedList<T> linkedList)
{
@@ -350,25 +350,25 @@ namespace TEngine
throw new GameFrameworkException("Linked list is invalid.");
}
m_Enumerator = linkedList.GetEnumerator();
_enumerator = linkedList.GetEnumerator();
}
/// <summary>
/// 获取当前结点。
/// </summary>
public T Current => m_Enumerator.Current;
public T Current => _enumerator.Current;
/// <summary>
/// 获取当前的枚举数。
/// </summary>
object IEnumerator.Current => m_Enumerator.Current;
object IEnumerator.Current => _enumerator.Current;
/// <summary>
/// 清理枚举数。
/// </summary>
public void Dispose()
{
m_Enumerator.Dispose();
_enumerator.Dispose();
}
/// <summary>
@@ -377,7 +377,7 @@ namespace TEngine
/// <returns>返回下一个结点。</returns>
public bool MoveNext()
{
return m_Enumerator.MoveNext();
return _enumerator.MoveNext();
}
/// <summary>
@@ -385,7 +385,7 @@ namespace TEngine
/// </summary>
void IEnumerator.Reset()
{
((IEnumerator<T>)m_Enumerator).Reset();
((IEnumerator<T>)_enumerator).Reset();
}
}
}

View File

@@ -118,9 +118,9 @@ namespace TEngine
[StructLayout(LayoutKind.Auto)]
public struct Enumerator : IEnumerator<T>, IEnumerator
{
private readonly GameFrameworkLinkedListRange<T> m_GameFrameworkLinkedListRange;
private LinkedListNode<T> m_Current;
private T m_CurrentValue;
private readonly GameFrameworkLinkedListRange<T> _gameFrameworkLinkedListRange;
private LinkedListNode<T> _current;
private T _currentValue;
internal Enumerator(GameFrameworkLinkedListRange<T> range)
{
@@ -129,20 +129,20 @@ namespace TEngine
throw new GameFrameworkException("Range is invalid.");
}
m_GameFrameworkLinkedListRange = range;
m_Current = m_GameFrameworkLinkedListRange._first;
m_CurrentValue = default(T);
_gameFrameworkLinkedListRange = range;
_current = _gameFrameworkLinkedListRange._first;
_currentValue = default(T);
}
/// <summary>
/// 获取当前结点。
/// </summary>
public T Current => m_CurrentValue;
public T Current => _currentValue;
/// <summary>
/// 获取当前的枚举数。
/// </summary>
object IEnumerator.Current => m_CurrentValue;
object IEnumerator.Current => _currentValue;
/// <summary>
/// 清理枚举数。
@@ -157,13 +157,13 @@ namespace TEngine
/// <returns>返回下一个结点。</returns>
public bool MoveNext()
{
if (m_Current == null || m_Current == m_GameFrameworkLinkedListRange._terminal)
if (_current == null || _current == _gameFrameworkLinkedListRange._terminal)
{
return false;
}
m_CurrentValue = m_Current.Value;
m_Current = m_Current.Next;
_currentValue = _current.Value;
_current = _current.Next;
return true;
}
@@ -172,8 +172,8 @@ namespace TEngine
/// </summary>
void IEnumerator.Reset()
{
m_Current = m_GameFrameworkLinkedListRange._first;
m_CurrentValue = default(T);
_current = _gameFrameworkLinkedListRange._first;
_currentValue = default(T);
}
}
}

View File

@@ -207,7 +207,7 @@ namespace TEngine
[StructLayout(LayoutKind.Auto)]
public struct Enumerator : IEnumerator<KeyValuePair<TKey, GameFrameworkLinkedListRange<TValue>>>, IEnumerator
{
private Dictionary<TKey, GameFrameworkLinkedListRange<TValue>>.Enumerator m_Enumerator;
private Dictionary<TKey, GameFrameworkLinkedListRange<TValue>>.Enumerator _enumerator;
internal Enumerator(Dictionary<TKey, GameFrameworkLinkedListRange<TValue>> dictionary)
{
@@ -216,25 +216,25 @@ namespace TEngine
throw new GameFrameworkException("Dictionary is invalid.");
}
m_Enumerator = dictionary.GetEnumerator();
_enumerator = dictionary.GetEnumerator();
}
/// <summary>
/// 获取当前结点。
/// </summary>
public KeyValuePair<TKey, GameFrameworkLinkedListRange<TValue>> Current => m_Enumerator.Current;
public KeyValuePair<TKey, GameFrameworkLinkedListRange<TValue>> Current => _enumerator.Current;
/// <summary>
/// 获取当前的枚举数。
/// </summary>
object IEnumerator.Current => m_Enumerator.Current;
object IEnumerator.Current => _enumerator.Current;
/// <summary>
/// 清理枚举数。
/// </summary>
public void Dispose()
{
m_Enumerator.Dispose();
_enumerator.Dispose();
}
/// <summary>
@@ -243,7 +243,7 @@ namespace TEngine
/// <returns>返回下一个结点。</returns>
public bool MoveNext()
{
return m_Enumerator.MoveNext();
return _enumerator.MoveNext();
}
/// <summary>
@@ -251,7 +251,7 @@ namespace TEngine
/// </summary>
void IEnumerator.Reset()
{
((IEnumerator<KeyValuePair<TKey, GameFrameworkLinkedListRange<TValue>>>)m_Enumerator).Reset();
((IEnumerator<KeyValuePair<TKey, GameFrameworkLinkedListRange<TValue>>>)_enumerator).Reset();
}
}
}

View File

@@ -34,24 +34,17 @@ namespace TEngine
/// <summary>
/// 所有事件。
/// </summary>
private readonly Dictionary<int, List<EventRegInfo>> _allEventListenerMap;
private readonly Dictionary<int, List<EventRegInfo>> _allEventListenerMap = new();
/// <summary>
/// 用于标记一个事件是不是正在处理。
/// </summary>
private readonly List<int> _processEventList;
private readonly List<int> _processEventList = new();
/// <summary>
/// 用于标记一个事件是不是被移除。
/// </summary>
private readonly List<int> _delayDeleteEventList;
public ActorEventDispatcher()
{
_processEventList = new List<int>();
_delayDeleteEventList = new List<int>();
_allEventListenerMap = new Dictionary<int, List<EventRegInfo>>();
}
private readonly List<int> _delayDeleteEventList = new();
/// <summary>
/// 移除所有事件监听。

View File

@@ -76,7 +76,7 @@ namespace TEngine
this.audioMixer = audioMixer;
_maxChannel = maxChannel;
_audioGroupConfig = audioGroupConfig;
AudioMixerGroup[] audioMixerGroups = audioMixer.FindMatchingGroups(Utility.Text.Format("Master/{0}", audioGroupConfig.AudioType.ToString()));
AudioMixerGroup[] audioMixerGroups = audioMixer.FindMatchingGroups(Utility.Text.Format("Master/{0}", audioGroupConfig.audioType.ToString()));
if (audioMixerGroups.Length > 0)
{
_audioMixerGroup = audioMixerGroups[0];

View File

@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace TEngine
{
@@ -9,19 +10,19 @@ namespace TEngine
[Serializable]
public sealed class AudioGroupConfig
{
[SerializeField] private string m_Name = null;
[SerializeField] private string name = null;
[SerializeField] private bool m_Mute = false;
[SerializeField] private bool mute = false;
[SerializeField, Range(0f, 1f)] private float m_Volume = 1f;
[SerializeField, Range(0f, 1f)] private float volume = 1f;
[SerializeField] private int m_AgentHelperCount = 1;
[SerializeField] private int agentHelperCount = 1;
/// <summary>
/// 音效分类,可分别关闭/开启对应分类音效。
/// </summary>
/// <remarks>命名与AudioMixer中分类名保持一致。</remarks>
public AudioType AudioType;
public AudioType audioType;
/// <summary>
/// 音频源中3D声音的衰减模式。
@@ -44,22 +45,22 @@ namespace TEngine
/// <summary>
/// 音频轨道组配置的名称。
/// </summary>
public string Name => m_Name;
public string Name => name;
/// <summary>
/// 是否禁用。
/// </summary>
public bool Mute => m_Mute;
public bool Mute => mute;
/// <summary>
/// 音量大小。
/// </summary>
public float Volume => m_Volume;
public float Volume => volume;
/// <summary>
/// 音频代理个数。
/// <remarks>命名与AudioMixer中个数保持一致。</remarks>
/// </summary>
public int AgentHelperCount => m_AgentHelperCount;
public int AgentHelperCount => agentHelperCount;
}
}

View File

@@ -389,7 +389,7 @@ namespace TEngine
for (int index = 0; index < (int)AudioType.Max; ++index)
{
AudioType audioType = (AudioType)index;
AudioGroupConfig audioGroupConfig = _audioGroupConfigs.First(t => t.AudioType == audioType);
AudioGroupConfig audioGroupConfig = _audioGroupConfigs.First(t => t.audioType == audioType);
_audioCategories[index] = new AudioCategory(audioGroupConfig.AgentHelperCount, _audioMixer, audioGroupConfig);
_categoriesVolume[index] = audioGroupConfig.Volume;
}

View File

@@ -10,22 +10,22 @@ namespace TEngine
/// </summary>
public sealed class LogNode : IMemory
{
private DateTime m_LogTime;
private int m_LogFrameCount;
private LogType m_LogType;
private string m_LogMessage;
private string m_StackTrack;
private DateTime _logTime;
private int _logFrameCount;
private LogType _logType;
private string _logMessage;
private string _stackTrack;
/// <summary>
/// 初始化日志记录结点的新实例。
/// </summary>
public LogNode()
{
m_LogTime = default(DateTime);
m_LogFrameCount = 0;
m_LogType = LogType.Error;
m_LogMessage = null;
m_StackTrack = null;
_logTime = default(DateTime);
_logFrameCount = 0;
_logType = LogType.Error;
_logMessage = null;
_stackTrack = null;
}
/// <summary>
@@ -35,7 +35,7 @@ namespace TEngine
{
get
{
return m_LogTime;
return _logTime;
}
}
@@ -46,7 +46,7 @@ namespace TEngine
{
get
{
return m_LogFrameCount;
return _logFrameCount;
}
}
@@ -57,7 +57,7 @@ namespace TEngine
{
get
{
return m_LogType;
return _logType;
}
}
@@ -68,7 +68,7 @@ namespace TEngine
{
get
{
return m_LogMessage;
return _logMessage;
}
}
@@ -79,7 +79,7 @@ namespace TEngine
{
get
{
return m_StackTrack;
return _stackTrack;
}
}
@@ -93,11 +93,11 @@ namespace TEngine
public static LogNode Create(LogType logType, string logMessage, string stackTrack)
{
LogNode logNode = MemoryPool.Acquire<LogNode>();
logNode.m_LogTime = DateTime.UtcNow;
logNode.m_LogFrameCount = Time.frameCount;
logNode.m_LogType = logType;
logNode.m_LogMessage = logMessage;
logNode.m_StackTrack = stackTrack;
logNode._logTime = DateTime.UtcNow;
logNode._logFrameCount = Time.frameCount;
logNode._logType = logType;
logNode._logMessage = logMessage;
logNode._stackTrack = stackTrack;
return logNode;
}
@@ -106,11 +106,11 @@ namespace TEngine
/// </summary>
public void Clear()
{
m_LogTime = default(DateTime);
m_LogFrameCount = 0;
m_LogType = LogType.Error;
m_LogMessage = null;
m_StackTrack = null;
_logTime = default(DateTime);
_logFrameCount = 0;
_logType = LogType.Error;
_logMessage = null;
_stackTrack = null;
}
}
}

View File

@@ -8,10 +8,10 @@ namespace TEngine
{
private sealed class MemoryPoolPoolInformationWindow : ScrollableDebuggerWindowBase
{
private readonly Dictionary<string, List<MemoryPoolInfo>> m_MemoryPoolInfos = new Dictionary<string, List<MemoryPoolInfo>>(StringComparer.Ordinal);
private readonly Comparison<MemoryPoolInfo> m_NormalClassNameComparer = NormalClassNameComparer;
private readonly Comparison<MemoryPoolInfo> m_FullClassNameComparer = FullClassNameComparer;
private bool m_ShowFullClassName = false;
private readonly Dictionary<string, List<MemoryPoolInfo>> _memoryPoolInfos = new Dictionary<string, List<MemoryPoolInfo>>(StringComparer.Ordinal);
private readonly Comparison<MemoryPoolInfo> _normalClassNameComparer = NormalClassNameComparer;
private readonly Comparison<MemoryPoolInfo> _fullClassNameComparer = FullClassNameComparer;
private bool _showFullClassName = false;
public override void Initialize(params object[] args)
{
@@ -27,30 +27,30 @@ namespace TEngine
}
GUILayout.EndVertical();
m_ShowFullClassName = GUILayout.Toggle(m_ShowFullClassName, "Show Full Class Name");
m_MemoryPoolInfos.Clear();
_showFullClassName = GUILayout.Toggle(_showFullClassName, "Show Full Class Name");
_memoryPoolInfos.Clear();
MemoryPoolInfo[] memoryPoolInfos = MemoryPool.GetAllMemoryPoolInfos();
foreach (MemoryPoolInfo memoryPoolInfo in memoryPoolInfos)
{
string assemblyName = memoryPoolInfo.Type.Assembly.GetName().Name;
List<MemoryPoolInfo> results = null;
if (!m_MemoryPoolInfos.TryGetValue(assemblyName, out results))
if (!_memoryPoolInfos.TryGetValue(assemblyName, out results))
{
results = new List<MemoryPoolInfo>();
m_MemoryPoolInfos.Add(assemblyName, results);
_memoryPoolInfos.Add(assemblyName, results);
}
results.Add(memoryPoolInfo);
}
foreach (KeyValuePair<string, List<MemoryPoolInfo>> assemblyMemoryPoolInfo in m_MemoryPoolInfos)
foreach (KeyValuePair<string, List<MemoryPoolInfo>> assemblyMemoryPoolInfo in _memoryPoolInfos)
{
GUILayout.Label(Utility.Text.Format("<b>Assembly: {0}</b>", assemblyMemoryPoolInfo.Key));
GUILayout.BeginVertical("box");
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(m_ShowFullClassName ? "<b>Full Class Name</b>" : "<b>Class Name</b>");
GUILayout.Label(_showFullClassName ? "<b>Full Class Name</b>" : "<b>Class Name</b>");
GUILayout.Label("<b>Unused</b>", GUILayout.Width(60f));
GUILayout.Label("<b>Using</b>", GUILayout.Width(60f));
GUILayout.Label("<b>Acquire</b>", GUILayout.Width(60f));
@@ -62,7 +62,7 @@ namespace TEngine
if (assemblyMemoryPoolInfo.Value.Count > 0)
{
assemblyMemoryPoolInfo.Value.Sort(m_ShowFullClassName ? m_FullClassNameComparer : m_NormalClassNameComparer);
assemblyMemoryPoolInfo.Value.Sort(_showFullClassName ? _fullClassNameComparer : _normalClassNameComparer);
foreach (MemoryPoolInfo memoryPoolInfo in assemblyMemoryPoolInfo.Value)
{
DrawMemoryPoolInfo(memoryPoolInfo);
@@ -81,7 +81,7 @@ namespace TEngine
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(m_ShowFullClassName ? memoryPoolInfo.Type.FullName : memoryPoolInfo.Type.Name);
GUILayout.Label(_showFullClassName ? memoryPoolInfo.Type.FullName : memoryPoolInfo.Type.Name);
GUILayout.Label(memoryPoolInfo.UnusedMemoryCount.ToString(), GUILayout.Width(60f));
GUILayout.Label(memoryPoolInfo.UsingMemoryCount.ToString(), GUILayout.Width(60f));
GUILayout.Label(memoryPoolInfo.AcquireMemoryCount.ToString(), GUILayout.Width(60f));

View File

@@ -1,61 +0,0 @@
// using UnityEngine;
//
// namespace TEngine
// {
// public sealed partial class DebuggerModule
// {
// private sealed class NetworkInformationWindow : ScrollableDebuggerWindowBase
// {
// private NetworkComponent m_NetworkComponent = null;
//
// public override void Initialize(params object[] args)
// {
// m_NetworkComponent = GameEntry.GetComponent<NetworkComponent>();
// if (m_NetworkComponent == null)
// {
// Log.Fatal("Network component is invalid.");
// return;
// }
// }
//
// protected override void OnDrawScrollableWindow()
// {
// GUILayout.Label("<b>Network Information</b>");
// GUILayout.BeginVertical("box");
// {
// DrawItem("Network Channel Count", m_NetworkComponent.NetworkChannelCount.ToString());
// }
// GUILayout.EndVertical();
// INetworkChannel[] networkChannels = m_NetworkComponent.GetAllNetworkChannels();
// for (int i = 0; i < networkChannels.Length; i++)
// {
// DrawNetworkChannel(networkChannels[i]);
// }
// }
//
// private void DrawNetworkChannel(INetworkChannel networkChannel)
// {
// GUILayout.Label(Utility.Text.Format("<b>Network Channel: {0} ({1})</b>", networkChannel.Name, networkChannel.Connected ? "Connected" : "Disconnected"));
// GUILayout.BeginVertical("box");
// {
// DrawItem("Service Type", networkChannel.ServiceType.ToString());
// DrawItem("Address Family", networkChannel.AddressFamily.ToString());
// DrawItem("Local Address", networkChannel.Connected ? networkChannel.Socket.LocalEndPoint.ToString() : "Unavailable");
// DrawItem("Remote Address", networkChannel.Connected ? networkChannel.Socket.RemoteEndPoint.ToString() : "Unavailable");
// DrawItem("Send Packet", Utility.Text.Format("{0} / {1}", networkChannel.SendPacketCount, networkChannel.SentPacketCount));
// DrawItem("Receive Packet", Utility.Text.Format("{0} / {1}", networkChannel.ReceivePacketCount, networkChannel.ReceivedPacketCount));
// DrawItem("Miss Heart Beat Count", networkChannel.MissHeartBeatCount.ToString());
// DrawItem("Heart Beat", Utility.Text.Format("{0:F2} / {1:F2}", networkChannel.HeartBeatElapseSeconds, networkChannel.HeartBeatInterval));
// if (networkChannel.Connected)
// {
// if (GUILayout.Button("Disconnect", GUILayout.Height(30f)))
// {
// networkChannel.Close();
// }
// }
// }
// GUILayout.EndVertical();
// }
// }
// }
// }

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 91eb2683b03a4eb0afdd2edd034df2cc
timeCreated: 1680489774

View File

@@ -6,7 +6,7 @@ namespace TEngine
{
private sealed class QualityInformationWindow : ScrollableDebuggerWindowBase
{
private bool m_ApplyExpensiveChanges = false;
private bool _applyExpensiveChanges = false;
protected override void OnDrawScrollableWindow()
{
@@ -16,12 +16,12 @@ namespace TEngine
int currentQualityLevel = QualitySettings.GetQualityLevel();
DrawItem("Current Quality Level", QualitySettings.names[currentQualityLevel]);
m_ApplyExpensiveChanges = GUILayout.Toggle(m_ApplyExpensiveChanges, "Apply expensive changes on quality level change.");
_applyExpensiveChanges = GUILayout.Toggle(_applyExpensiveChanges, "Apply expensive changes on quality level change.");
int newQualityLevel = GUILayout.SelectionGrid(currentQualityLevel, QualitySettings.names, 3, "toggle");
if (newQualityLevel != currentQualityLevel)
{
QualitySettings.SetQualityLevel(newQualityLevel, m_ApplyExpensiveChanges);
QualitySettings.SetQualityLevel(newQualityLevel, _applyExpensiveChanges);
}
}
GUILayout.EndVertical();

View File

@@ -6,24 +6,24 @@
{
private sealed class Sample
{
private readonly string m_Name;
private readonly string m_Type;
private readonly long m_Size;
private bool m_Highlight;
private readonly string _name;
private readonly string _type;
private readonly long _size;
private bool _highlight;
public Sample(string name, string type, long size)
{
m_Name = name;
m_Type = type;
m_Size = size;
m_Highlight = false;
_name = name;
_type = type;
_size = size;
_highlight = false;
}
public string Name
{
get
{
return m_Name;
return _name;
}
}
@@ -31,7 +31,7 @@
{
get
{
return m_Type;
return _type;
}
}
@@ -39,7 +39,7 @@
{
get
{
return m_Size;
return _size;
}
}
@@ -47,11 +47,11 @@
{
get
{
return m_Highlight;
return _highlight;
}
set
{
m_Highlight = value;
_highlight = value;
}
}
}

View File

@@ -13,12 +13,12 @@ namespace TEngine
{
private const int ShowSampleCount = 300;
private readonly List<Sample> m_Samples = new List<Sample>();
private readonly Comparison<Sample> m_SampleComparer = SampleComparer;
private DateTime m_SampleTime = DateTime.MinValue;
private long m_SampleSize = 0L;
private long m_DuplicateSampleSize = 0L;
private int m_DuplicateSimpleCount = 0;
private readonly List<Sample> _samples = new List<Sample>();
private readonly Comparison<Sample> _sampleComparer = SampleComparer;
private DateTime _sampleTime = DateTime.MinValue;
private long _sampleSize = 0L;
private long _duplicateSampleSize = 0L;
private int _duplicateSimpleCount = 0;
protected override void OnDrawScrollableWindow()
{
@@ -31,22 +31,22 @@ namespace TEngine
TakeSample();
}
if (m_SampleTime <= DateTime.MinValue)
if (_sampleTime <= DateTime.MinValue)
{
GUILayout.Label(Utility.Text.Format("<b>Please take sample for {0} first.</b>", typeName));
}
else
{
if (m_DuplicateSimpleCount > 0)
if (_duplicateSimpleCount > 0)
{
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}, while {4} {1}s ({5}) might be duplicated.</b>", m_Samples.Count, typeName, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime(), m_DuplicateSimpleCount, GetByteLengthString(m_DuplicateSampleSize)));
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}, while {4} {1}s ({5}) might be duplicated.</b>", _samples.Count, typeName, GetByteLengthString(_sampleSize), _sampleTime.ToLocalTime(), _duplicateSimpleCount, GetByteLengthString(_duplicateSampleSize)));
}
else
{
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}.</b>", m_Samples.Count, typeName, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime()));
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}.</b>", _samples.Count, typeName, GetByteLengthString(_sampleSize), _sampleTime.ToLocalTime()));
}
if (m_Samples.Count > 0)
if (_samples.Count > 0)
{
GUILayout.BeginHorizontal();
{
@@ -58,13 +58,13 @@ namespace TEngine
}
int count = 0;
for (int i = 0; i < m_Samples.Count; i++)
for (int i = 0; i < _samples.Count; i++)
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", m_Samples[i].Name) : m_Samples[i].Name);
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", m_Samples[i].Type) : m_Samples[i].Type, GUILayout.Width(240f));
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", GetByteLengthString(m_Samples[i].Size)) : GetByteLengthString(m_Samples[i].Size), GUILayout.Width(80f));
GUILayout.Label(_samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", _samples[i].Name) : _samples[i].Name);
GUILayout.Label(_samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", _samples[i].Type) : _samples[i].Type, GUILayout.Width(240f));
GUILayout.Label(_samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", GetByteLengthString(_samples[i].Size)) : GetByteLengthString(_samples[i].Size), GUILayout.Width(80f));
}
GUILayout.EndHorizontal();
@@ -81,11 +81,11 @@ namespace TEngine
private void TakeSample()
{
m_SampleTime = DateTime.UtcNow;
m_SampleSize = 0L;
m_DuplicateSampleSize = 0L;
m_DuplicateSimpleCount = 0;
m_Samples.Clear();
_sampleTime = DateTime.UtcNow;
_sampleSize = 0L;
_duplicateSampleSize = 0L;
_duplicateSimpleCount = 0;
_samples.Clear();
T[] samples = Resources.FindObjectsOfTypeAll<T>();
for (int i = 0; i < samples.Length; i++)
@@ -96,19 +96,19 @@ namespace TEngine
#else
sampleSize = Profiler.GetRuntimeMemorySize(samples[i]);
#endif
m_SampleSize += sampleSize;
m_Samples.Add(new Sample(samples[i].name, samples[i].GetType().Name, sampleSize));
_sampleSize += sampleSize;
_samples.Add(new Sample(samples[i].name, samples[i].GetType().Name, sampleSize));
}
m_Samples.Sort(m_SampleComparer);
_samples.Sort(_sampleComparer);
for (int i = 1; i < m_Samples.Count; i++)
for (int i = 1; i < _samples.Count; i++)
{
if (m_Samples[i].Name == m_Samples[i - 1].Name && m_Samples[i].Type == m_Samples[i - 1].Type && m_Samples[i].Size == m_Samples[i - 1].Size)
if (_samples[i].Name == _samples[i - 1].Name && _samples[i].Type == _samples[i - 1].Type && _samples[i].Size == _samples[i - 1].Size)
{
m_Samples[i].Highlight = true;
m_DuplicateSampleSize += m_Samples[i].Size;
m_DuplicateSimpleCount++;
_samples[i].Highlight = true;
_duplicateSampleSize += _samples[i].Size;
_duplicateSimpleCount++;
}
}
}

View File

@@ -6,22 +6,22 @@
{
private sealed class Record
{
private readonly string m_Name;
private int m_Count;
private long m_Size;
private readonly string _name;
private int _count;
private long _size;
public Record(string name)
{
m_Name = name;
m_Count = 0;
m_Size = 0L;
_name = name;
_count = 0;
_size = 0L;
}
public string Name
{
get
{
return m_Name;
return _name;
}
}
@@ -29,11 +29,11 @@
{
get
{
return m_Count;
return _count;
}
set
{
m_Count = value;
_count = value;
}
}
@@ -41,11 +41,11 @@
{
get
{
return m_Size;
return _size;
}
set
{
m_Size = value;
_size = value;
}
}
}

View File

@@ -11,11 +11,11 @@ namespace TEngine
{
private sealed partial class RuntimeMemorySummaryWindow : ScrollableDebuggerWindowBase
{
private readonly List<Record> m_Records = new List<Record>();
private readonly Comparison<Record> m_RecordComparer = RecordComparer;
private DateTime m_SampleTime = DateTime.MinValue;
private int m_SampleCount = 0;
private long m_SampleSize = 0L;
private readonly List<Record> _records = new List<Record>();
private readonly Comparison<Record> _recordComparer = RecordComparer;
private DateTime _sampleTime = DateTime.MinValue;
private int _sampleCount = 0;
private long _sampleSize = 0L;
protected override void OnDrawScrollableWindow()
{
@@ -27,13 +27,13 @@ namespace TEngine
TakeSample();
}
if (m_SampleTime <= DateTime.MinValue)
if (_sampleTime <= DateTime.MinValue)
{
GUILayout.Label("<b>Please take sample first.</b>");
}
else
{
GUILayout.Label(Utility.Text.Format("<b>{0} Objects ({1}) obtained at {2:yyyy-MM-dd HH:mm:ss}.</b>", m_SampleCount, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime()));
GUILayout.Label(Utility.Text.Format("<b>{0} Objects ({1}) obtained at {2:yyyy-MM-dd HH:mm:ss}.</b>", _sampleCount, GetByteLengthString(_sampleSize), _sampleTime.ToLocalTime()));
GUILayout.BeginHorizontal();
{
@@ -43,13 +43,13 @@ namespace TEngine
}
GUILayout.EndHorizontal();
for (int i = 0; i < m_Records.Count; i++)
for (int i = 0; i < _records.Count; i++)
{
GUILayout.BeginHorizontal();
{
GUILayout.Label(m_Records[i].Name);
GUILayout.Label(m_Records[i].Count.ToString(), GUILayout.Width(120f));
GUILayout.Label(GetByteLengthString(m_Records[i].Size), GUILayout.Width(120f));
GUILayout.Label(_records[i].Name);
GUILayout.Label(_records[i].Count.ToString(), GUILayout.Width(120f));
GUILayout.Label(GetByteLengthString(_records[i].Size), GUILayout.Width(120f));
}
GUILayout.EndHorizontal();
}
@@ -60,10 +60,10 @@ namespace TEngine
private void TakeSample()
{
m_Records.Clear();
m_SampleTime = DateTime.UtcNow;
m_SampleCount = 0;
m_SampleSize = 0L;
_records.Clear();
_sampleTime = DateTime.UtcNow;
_sampleCount = 0;
_sampleSize = 0L;
UnityEngine.Object[] samples = Resources.FindObjectsOfTypeAll<UnityEngine.Object>();
for (int i = 0; i < samples.Length; i++)
@@ -75,11 +75,11 @@ namespace TEngine
sampleSize = Profiler.GetRuntimeMemorySize(samples[i]);
#endif
string name = samples[i].GetType().Name;
m_SampleCount++;
m_SampleSize += sampleSize;
_sampleCount++;
_sampleSize += sampleSize;
Record record = null;
foreach (Record r in m_Records)
foreach (Record r in _records)
{
if (r.Name == name)
{
@@ -91,14 +91,14 @@ namespace TEngine
if (record == null)
{
record = new Record(name);
m_Records.Add(record);
_records.Add(record);
}
record.Count++;
record.Size += sampleSize;
}
m_Records.Sort(m_RecordComparer);
_records.Sort(_recordComparer);
}
private static int RecordComparer(Record a, Record b)

View File

@@ -7,7 +7,7 @@ namespace TEngine
private abstract class ScrollableDebuggerWindowBase : IDebuggerWindow
{
private const float TitleWidth = 240f;
private Vector2 m_ScrollPosition = Vector2.zero;
private Vector2 _scrollPosition = Vector2.zero;
public virtual void Initialize(params object[] args)
{
@@ -31,7 +31,7 @@ namespace TEngine
public void OnDraw()
{
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
_scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
{
OnDrawScrollableWindow();
}

View File

@@ -8,13 +8,13 @@ namespace TEngine
private sealed class SettingsWindow : ScrollableDebuggerWindowBase
{
private Debugger _debugger = null;
private float m_LastIconX = 0f;
private float m_LastIconY = 0f;
private float m_LastWindowX = 0f;
private float m_LastWindowY = 0f;
private float m_LastWindowWidth = 0f;
private float m_LastWindowHeight = 0f;
private float m_LastWindowScale = 0f;
private float _lastIconX = 0f;
private float _lastIconY = 0f;
private float _lastWindowX = 0f;
private float _lastWindowY = 0f;
private float _lastWindowWidth = 0f;
private float _lastWindowHeight = 0f;
private float _lastWindowScale = 0f;
public override void Initialize(params object[] args)
{
@@ -25,59 +25,59 @@ namespace TEngine
return;
}
m_LastIconX = PlayerPrefs.GetFloat("Debugger.Icon.X", DefaultIconRect.x);
m_LastIconY = PlayerPrefs.GetFloat("Debugger.Icon.Y", DefaultIconRect.y);
m_LastWindowX = PlayerPrefs.GetFloat("Debugger.Window.X", DefaultWindowRect.x);
m_LastWindowY = PlayerPrefs.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
m_LastWindowWidth = PlayerPrefs.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
m_LastWindowHeight = PlayerPrefs.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
_lastIconX = PlayerPrefs.GetFloat("Debugger.Icon.X", DefaultIconRect.x);
_lastIconY = PlayerPrefs.GetFloat("Debugger.Icon.Y", DefaultIconRect.y);
_lastWindowX = PlayerPrefs.GetFloat("Debugger.Window.X", DefaultWindowRect.x);
_lastWindowY = PlayerPrefs.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
_lastWindowWidth = PlayerPrefs.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
_lastWindowHeight = PlayerPrefs.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
_debugger.WindowScale = m_LastWindowScale = PlayerPrefs.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
_debugger.IconRect = new Rect(m_LastIconX, m_LastIconY, DefaultIconRect.width, DefaultIconRect.height);
_debugger.WindowRect = new Rect(m_LastWindowX, m_LastWindowY, m_LastWindowWidth, m_LastWindowHeight);
_debugger.WindowScale = _lastWindowScale = PlayerPrefs.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
_debugger.IconRect = new Rect(_lastIconX, _lastIconY, DefaultIconRect.width, DefaultIconRect.height);
_debugger.WindowRect = new Rect(_lastWindowX, _lastWindowY, _lastWindowWidth, _lastWindowHeight);
}
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
if (Math.Abs(m_LastIconX - _debugger.IconRect.x) > 0.01f)
if (Math.Abs(_lastIconX - _debugger.IconRect.x) > 0.01f)
{
m_LastIconX = _debugger.IconRect.x;
_lastIconX = _debugger.IconRect.x;
PlayerPrefs.SetFloat("Debugger.Icon.X", _debugger.IconRect.x);
}
if (Math.Abs(m_LastIconY - _debugger.IconRect.y) > 0.01f)
if (Math.Abs(_lastIconY - _debugger.IconRect.y) > 0.01f)
{
m_LastIconY = _debugger.IconRect.y;
_lastIconY = _debugger.IconRect.y;
PlayerPrefs.SetFloat("Debugger.Icon.Y", _debugger.IconRect.y);
}
if (Math.Abs(m_LastWindowX - _debugger.WindowRect.x) > 0.01f)
if (Math.Abs(_lastWindowX - _debugger.WindowRect.x) > 0.01f)
{
m_LastWindowX = _debugger.WindowRect.x;
_lastWindowX = _debugger.WindowRect.x;
PlayerPrefs.SetFloat("Debugger.Window.X", _debugger.WindowRect.x);
}
if (Math.Abs(m_LastWindowY - _debugger.WindowRect.y) > 0.01f)
if (Math.Abs(_lastWindowY - _debugger.WindowRect.y) > 0.01f)
{
m_LastWindowY = _debugger.WindowRect.y;
_lastWindowY = _debugger.WindowRect.y;
PlayerPrefs.SetFloat("Debugger.Window.Y", _debugger.WindowRect.y);
}
if (Math.Abs(m_LastWindowWidth - _debugger.WindowRect.width) > 0.01f)
if (Math.Abs(_lastWindowWidth - _debugger.WindowRect.width) > 0.01f)
{
m_LastWindowWidth = _debugger.WindowRect.width;
_lastWindowWidth = _debugger.WindowRect.width;
PlayerPrefs.SetFloat("Debugger.Window.Width", _debugger.WindowRect.width);
}
if (Math.Abs(m_LastWindowHeight - _debugger.WindowRect.height) > 0.01f)
if (Math.Abs(_lastWindowHeight - _debugger.WindowRect.height) > 0.01f)
{
m_LastWindowHeight = _debugger.WindowRect.height;
_lastWindowHeight = _debugger.WindowRect.height;
PlayerPrefs.SetFloat("Debugger.Window.Height", _debugger.WindowRect.height);
}
if (Math.Abs(m_LastWindowScale - _debugger.WindowScale) > 0.01f)
if (Math.Abs(_lastWindowScale - _debugger.WindowScale) > 0.01f)
{
m_LastWindowScale = _debugger.WindowScale;
_lastWindowScale = _debugger.WindowScale;
PlayerPrefs.SetFloat("Debugger.Window.Scale", _debugger.WindowScale);
}
}

View File

@@ -1,4 +1,5 @@
using UnityEngine;
using System.Globalization;
using UnityEngine;
namespace TEngine
{
@@ -12,30 +13,30 @@ namespace TEngine
GUILayout.BeginVertical("box");
{
DrawItem("Time Scale", Utility.Text.Format("{0} [{1}]", Time.timeScale, GetTimeScaleDescription(Time.timeScale)));
DrawItem("Realtime Since Startup", Time.realtimeSinceStartup.ToString());
DrawItem("Time Since Level Load", Time.timeSinceLevelLoad.ToString());
DrawItem("Time", Time.time.ToString());
DrawItem("Fixed Time", Time.fixedTime.ToString());
DrawItem("Unscaled Time", Time.unscaledTime.ToString());
DrawItem("Realtime Since Startup", Time.realtimeSinceStartup.ToString(CultureInfo.InvariantCulture));
DrawItem("Time Since Level Load", Time.timeSinceLevelLoad.ToString(CultureInfo.InvariantCulture));
DrawItem("Time", Time.time.ToString(CultureInfo.InvariantCulture));
DrawItem("Fixed Time", Time.fixedTime.ToString(CultureInfo.InvariantCulture));
DrawItem("Unscaled Time", Time.unscaledTime.ToString(CultureInfo.InvariantCulture));
#if UNITY_5_6_OR_NEWER
DrawItem("Fixed Unscaled Time", Time.fixedUnscaledTime.ToString());
DrawItem("Fixed Unscaled Time", Time.fixedUnscaledTime.ToString(CultureInfo.InvariantCulture));
#endif
DrawItem("Delta Time", Time.deltaTime.ToString());
DrawItem("Fixed Delta Time", Time.fixedDeltaTime.ToString());
DrawItem("Unscaled Delta Time", Time.unscaledDeltaTime.ToString());
DrawItem("Delta Time", Time.deltaTime.ToString(CultureInfo.InvariantCulture));
DrawItem("Fixed Delta Time", Time.fixedDeltaTime.ToString(CultureInfo.InvariantCulture));
DrawItem("Unscaled Delta Time", Time.unscaledDeltaTime.ToString(CultureInfo.InvariantCulture));
#if UNITY_5_6_OR_NEWER
DrawItem("Fixed Unscaled Delta Time", Time.fixedUnscaledDeltaTime.ToString());
DrawItem("Fixed Unscaled Delta Time", Time.fixedUnscaledDeltaTime.ToString(CultureInfo.InvariantCulture));
#endif
DrawItem("Smooth Delta Time", Time.smoothDeltaTime.ToString());
DrawItem("Maximum Delta Time", Time.maximumDeltaTime.ToString());
DrawItem("Smooth Delta Time", Time.smoothDeltaTime.ToString(CultureInfo.InvariantCulture));
DrawItem("Maximum Delta Time", Time.maximumDeltaTime.ToString(CultureInfo.InvariantCulture));
#if UNITY_5_5_OR_NEWER
DrawItem("Maximum Particle Delta Time", Time.maximumParticleDeltaTime.ToString());
DrawItem("Maximum Particle Delta Time", Time.maximumParticleDeltaTime.ToString(CultureInfo.InvariantCulture));
#endif
DrawItem("Frame Count", Time.frameCount.ToString());
DrawItem("Rendered Frame Count", Time.renderedFrameCount.ToString());
DrawItem("Capture Framerate", Time.captureFramerate.ToString());
#if UNITY_2019_2_OR_NEWER
DrawItem("Capture Delta Time", Time.captureDeltaTime.ToString());
DrawItem("Capture Delta Time", Time.captureDeltaTime.ToString(CultureInfo.InvariantCulture));
#endif
#if UNITY_5_6_OR_NEWER
DrawItem("In Fixed Time Step", Time.inFixedTimeStep.ToString());

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
using Object = UnityEngine.Object;
namespace TEngine
@@ -31,56 +32,55 @@ namespace TEngine
private static TextEditor s_TextEditor = null;
private IDebuggerModule _debuggerModule = null;
private Rect m_DragRect = new Rect(0f, 0f, float.MaxValue, 25f);
private Rect m_IconRect = DefaultIconRect;
private Rect m_WindowRect = DefaultWindowRect;
private float m_WindowScale = DefaultWindowScale;
private readonly Rect _dragRect = new Rect(0f, 0f, float.MaxValue, 25f);
private Rect _iconRect = DefaultIconRect;
private Rect _windowRect = DefaultWindowRect;
private float _windowScale = DefaultWindowScale;
[SerializeField]
private GUISkin m_Skin = null;
private GUISkin skin = null;
[SerializeField]
private DebuggerActiveWindowType m_ActiveWindow = DebuggerActiveWindowType.AlwaysOpen;
private DebuggerActiveWindowType activeWindow = DebuggerActiveWindowType.AlwaysOpen;
public DebuggerActiveWindowType ActiveWindowType => m_ActiveWindow;
public DebuggerActiveWindowType ActiveWindowType => activeWindow;
[SerializeField]
private bool m_ShowFullWindow = false;
private bool _showFullWindow = false;
[SerializeField]
private ConsoleWindow m_ConsoleWindow = new ConsoleWindow();
private ConsoleWindow _consoleWindow = new ConsoleWindow();
private SystemInformationWindow m_SystemInformationWindow = new SystemInformationWindow();
private EnvironmentInformationWindow m_EnvironmentInformationWindow = new EnvironmentInformationWindow();
private ScreenInformationWindow m_ScreenInformationWindow = new ScreenInformationWindow();
private GraphicsInformationWindow m_GraphicsInformationWindow = new GraphicsInformationWindow();
private InputSummaryInformationWindow m_InputSummaryInformationWindow = new InputSummaryInformationWindow();
private InputTouchInformationWindow m_InputTouchInformationWindow = new InputTouchInformationWindow();
private InputLocationInformationWindow m_InputLocationInformationWindow = new InputLocationInformationWindow();
private InputAccelerationInformationWindow m_InputAccelerationInformationWindow = new InputAccelerationInformationWindow();
private InputGyroscopeInformationWindow m_InputGyroscopeInformationWindow = new InputGyroscopeInformationWindow();
private InputCompassInformationWindow m_InputCompassInformationWindow = new InputCompassInformationWindow();
private PathInformationWindow m_PathInformationWindow = new PathInformationWindow();
private SceneInformationWindow m_SceneInformationWindow = new SceneInformationWindow();
private TimeInformationWindow m_TimeInformationWindow = new TimeInformationWindow();
private QualityInformationWindow m_QualityInformationWindow = new QualityInformationWindow();
private ProfilerInformationWindow m_ProfilerInformationWindow = new ProfilerInformationWindow();
private RuntimeMemorySummaryWindow m_RuntimeMemorySummaryWindow = new RuntimeMemorySummaryWindow();
private RuntimeMemoryInformationWindow<Object> m_RuntimeMemoryAllInformationWindow = new RuntimeMemoryInformationWindow<Object>();
private RuntimeMemoryInformationWindow<Texture> m_RuntimeMemoryTextureInformationWindow = new RuntimeMemoryInformationWindow<Texture>();
private RuntimeMemoryInformationWindow<Mesh> m_RuntimeMemoryMeshInformationWindow = new RuntimeMemoryInformationWindow<Mesh>();
private RuntimeMemoryInformationWindow<Material> m_RuntimeMemoryMaterialInformationWindow = new RuntimeMemoryInformationWindow<Material>();
private RuntimeMemoryInformationWindow<Shader> m_RuntimeMemoryShaderInformationWindow = new RuntimeMemoryInformationWindow<Shader>();
private RuntimeMemoryInformationWindow<AnimationClip> m_RuntimeMemoryAnimationClipInformationWindow = new RuntimeMemoryInformationWindow<AnimationClip>();
private RuntimeMemoryInformationWindow<AudioClip> m_RuntimeMemoryAudioClipInformationWindow = new RuntimeMemoryInformationWindow<AudioClip>();
private RuntimeMemoryInformationWindow<Font> m_RuntimeMemoryFontInformationWindow = new RuntimeMemoryInformationWindow<Font>();
private RuntimeMemoryInformationWindow<TextAsset> m_RuntimeMemoryTextAssetInformationWindow = new RuntimeMemoryInformationWindow<TextAsset>();
private RuntimeMemoryInformationWindow<ScriptableObject> m_RuntimeMemoryScriptableObjectInformationWindow = new RuntimeMemoryInformationWindow<ScriptableObject>();
private MemoryPoolPoolInformationWindow _mMemoryPoolPoolInformationWindow = new MemoryPoolPoolInformationWindow();
// private NetworkInformationWindow m_NetworkInformationWindow = new NetworkInformationWindow();
private SettingsWindow m_SettingsWindow = new SettingsWindow();
private SystemInformationWindow _systemInformationWindow = new SystemInformationWindow();
private EnvironmentInformationWindow _environmentInformationWindow = new EnvironmentInformationWindow();
private ScreenInformationWindow _screenInformationWindow = new ScreenInformationWindow();
private GraphicsInformationWindow _graphicsInformationWindow = new GraphicsInformationWindow();
private InputSummaryInformationWindow _inputSummaryInformationWindow = new InputSummaryInformationWindow();
private InputTouchInformationWindow _inputTouchInformationWindow = new InputTouchInformationWindow();
private InputLocationInformationWindow _inputLocationInformationWindow = new InputLocationInformationWindow();
private InputAccelerationInformationWindow _inputAccelerationInformationWindow = new InputAccelerationInformationWindow();
private InputGyroscopeInformationWindow _inputGyroscopeInformationWindow = new InputGyroscopeInformationWindow();
private InputCompassInformationWindow _inputCompassInformationWindow = new InputCompassInformationWindow();
private PathInformationWindow _pathInformationWindow = new PathInformationWindow();
private SceneInformationWindow _sceneInformationWindow = new SceneInformationWindow();
private TimeInformationWindow _timeInformationWindow = new TimeInformationWindow();
private QualityInformationWindow _qualityInformationWindow = new QualityInformationWindow();
private ProfilerInformationWindow _profilerInformationWindow = new ProfilerInformationWindow();
private RuntimeMemorySummaryWindow _runtimeMemorySummaryWindow = new RuntimeMemorySummaryWindow();
private RuntimeMemoryInformationWindow<Object> _runtimeMemoryAllInformationWindow = new RuntimeMemoryInformationWindow<Object>();
private RuntimeMemoryInformationWindow<Texture> _runtimeMemoryTextureInformationWindow = new RuntimeMemoryInformationWindow<Texture>();
private RuntimeMemoryInformationWindow<Mesh> _runtimeMemoryMeshInformationWindow = new RuntimeMemoryInformationWindow<Mesh>();
private RuntimeMemoryInformationWindow<Material> _runtimeMemoryMaterialInformationWindow = new RuntimeMemoryInformationWindow<Material>();
private RuntimeMemoryInformationWindow<Shader> _runtimeMemoryShaderInformationWindow = new RuntimeMemoryInformationWindow<Shader>();
private RuntimeMemoryInformationWindow<AnimationClip> _runtimeMemoryAnimationClipInformationWindow = new RuntimeMemoryInformationWindow<AnimationClip>();
private RuntimeMemoryInformationWindow<AudioClip> _runtimeMemoryAudioClipInformationWindow = new RuntimeMemoryInformationWindow<AudioClip>();
private RuntimeMemoryInformationWindow<Font> _runtimeMemoryFontInformationWindow = new RuntimeMemoryInformationWindow<Font>();
private RuntimeMemoryInformationWindow<TextAsset> _runtimeMemoryTextAssetInformationWindow = new RuntimeMemoryInformationWindow<TextAsset>();
private RuntimeMemoryInformationWindow<ScriptableObject> _runtimeMemoryScriptableObjectInformationWindow = new RuntimeMemoryInformationWindow<ScriptableObject>();
private MemoryPoolPoolInformationWindow _memoryPoolPoolInformationWindow = new MemoryPoolPoolInformationWindow();
private SettingsWindow _settingsWindow = new SettingsWindow();
private FpsCounter m_FpsCounter = null;
private FpsCounter _fpsCounter = null;
/// <summary>
/// 获取或设置调试器窗口是否激活。
@@ -100,14 +100,14 @@ namespace TEngine
/// </summary>
public bool ShowFullWindow
{
get => m_ShowFullWindow;
get => _showFullWindow;
set
{
if (_eventSystem != null)
{
_eventSystem.SetActive(!value);
}
m_ShowFullWindow = value;
_showFullWindow = value;
}
}
@@ -116,8 +116,8 @@ namespace TEngine
/// </summary>
public Rect IconRect
{
get => m_IconRect;
set => m_IconRect = value;
get => _iconRect;
set => _iconRect = value;
}
/// <summary>
@@ -125,8 +125,8 @@ namespace TEngine
/// </summary>
public Rect WindowRect
{
get => m_WindowRect;
set => m_WindowRect = value;
get => _windowRect;
set => _windowRect = value;
}
/// <summary>
@@ -134,8 +134,8 @@ namespace TEngine
/// </summary>
public float WindowScale
{
get => m_WindowScale;
set => m_WindowScale = value;
get => _windowScale;
set => _windowScale = value;
}
private GameObject _eventSystem;
@@ -164,7 +164,7 @@ namespace TEngine
return;
}
m_FpsCounter = new FpsCounter(0.5f);
_fpsCounter = new FpsCounter(0.5f);
var lastIconX = PlayerPrefs.GetFloat("Debugger.Icon.X", DefaultIconRect.x);
var lastIconY = PlayerPrefs.GetFloat("Debugger.Icon.Y", DefaultIconRect.y);
@@ -172,46 +172,45 @@ namespace TEngine
var lastWindowY = PlayerPrefs.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
var lastWindowWidth = PlayerPrefs.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
var lastWindowHeight = PlayerPrefs.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
m_WindowScale = PlayerPrefs.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
m_WindowRect = new Rect(lastIconX, lastIconY, DefaultIconRect.width, DefaultIconRect.height);
m_WindowRect = new Rect(lastWindowX, lastWindowY, lastWindowWidth, lastWindowHeight);
_windowScale = PlayerPrefs.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
_windowRect = new Rect(lastIconX, lastIconY, DefaultIconRect.width, DefaultIconRect.height);
_windowRect = new Rect(lastWindowX, lastWindowY, lastWindowWidth, lastWindowHeight);
}
private void Start()
{
Initialize();
RegisterDebuggerWindow("Console", m_ConsoleWindow);
RegisterDebuggerWindow("Information/System", m_SystemInformationWindow);
RegisterDebuggerWindow("Information/Environment", m_EnvironmentInformationWindow);
RegisterDebuggerWindow("Information/Screen", m_ScreenInformationWindow);
RegisterDebuggerWindow("Information/Graphics", m_GraphicsInformationWindow);
RegisterDebuggerWindow("Information/Input/Summary", m_InputSummaryInformationWindow);
RegisterDebuggerWindow("Information/Input/Touch", m_InputTouchInformationWindow);
RegisterDebuggerWindow("Information/Input/Location", m_InputLocationInformationWindow);
RegisterDebuggerWindow("Information/Input/Acceleration", m_InputAccelerationInformationWindow);
RegisterDebuggerWindow("Information/Input/Gyroscope", m_InputGyroscopeInformationWindow);
RegisterDebuggerWindow("Information/Input/Compass", m_InputCompassInformationWindow);
RegisterDebuggerWindow("Information/Other/Scene", m_SceneInformationWindow);
RegisterDebuggerWindow("Information/Other/Path", m_PathInformationWindow);
RegisterDebuggerWindow("Information/Other/Time", m_TimeInformationWindow);
RegisterDebuggerWindow("Information/Other/Quality", m_QualityInformationWindow);
RegisterDebuggerWindow("Profiler/Summary", m_ProfilerInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Summary", m_RuntimeMemorySummaryWindow);
RegisterDebuggerWindow("Profiler/Memory/All", m_RuntimeMemoryAllInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Texture", m_RuntimeMemoryTextureInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Mesh", m_RuntimeMemoryMeshInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Material", m_RuntimeMemoryMaterialInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Shader", m_RuntimeMemoryShaderInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/AnimationClip", m_RuntimeMemoryAnimationClipInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/AudioClip", m_RuntimeMemoryAudioClipInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Font", m_RuntimeMemoryFontInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/TextAsset", m_RuntimeMemoryTextAssetInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/ScriptableObject", m_RuntimeMemoryScriptableObjectInformationWindow);
RegisterDebuggerWindow("Profiler/Reference Pool", _mMemoryPoolPoolInformationWindow);
// RegisterDebuggerWindow("Profiler/Network", m_NetworkInformationWindow);
RegisterDebuggerWindow("Other/Settings", m_SettingsWindow);
RegisterDebuggerWindow("Console", _consoleWindow);
RegisterDebuggerWindow("Information/System", _systemInformationWindow);
RegisterDebuggerWindow("Information/Environment", _environmentInformationWindow);
RegisterDebuggerWindow("Information/Screen", _screenInformationWindow);
RegisterDebuggerWindow("Information/Graphics", _graphicsInformationWindow);
RegisterDebuggerWindow("Information/Input/Summary", _inputSummaryInformationWindow);
RegisterDebuggerWindow("Information/Input/Touch", _inputTouchInformationWindow);
RegisterDebuggerWindow("Information/Input/Location", _inputLocationInformationWindow);
RegisterDebuggerWindow("Information/Input/Acceleration", _inputAccelerationInformationWindow);
RegisterDebuggerWindow("Information/Input/Gyroscope", _inputGyroscopeInformationWindow);
RegisterDebuggerWindow("Information/Input/Compass", _inputCompassInformationWindow);
RegisterDebuggerWindow("Information/Other/Scene", _sceneInformationWindow);
RegisterDebuggerWindow("Information/Other/Path", _pathInformationWindow);
RegisterDebuggerWindow("Information/Other/Time", _timeInformationWindow);
RegisterDebuggerWindow("Information/Other/Quality", _qualityInformationWindow);
RegisterDebuggerWindow("Profiler/Summary", _profilerInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Summary", _runtimeMemorySummaryWindow);
RegisterDebuggerWindow("Profiler/Memory/All", _runtimeMemoryAllInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Texture", _runtimeMemoryTextureInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Mesh", _runtimeMemoryMeshInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Material", _runtimeMemoryMaterialInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Shader", _runtimeMemoryShaderInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/AnimationClip", _runtimeMemoryAnimationClipInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/AudioClip", _runtimeMemoryAudioClipInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/Font", _runtimeMemoryFontInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/TextAsset", _runtimeMemoryTextAssetInformationWindow);
RegisterDebuggerWindow("Profiler/Memory/ScriptableObject", _runtimeMemoryScriptableObjectInformationWindow);
RegisterDebuggerWindow("Profiler/Reference Pool", _memoryPoolPoolInformationWindow);
RegisterDebuggerWindow("Other/Settings", _settingsWindow);
switch (m_ActiveWindow)
switch (activeWindow)
{
case DebuggerActiveWindowType.AlwaysOpen:
ActiveWindow = true;
@@ -233,7 +232,7 @@ namespace TEngine
private void Update()
{
m_FpsCounter.Update(Time.deltaTime, Time.unscaledDeltaTime);
_fpsCounter.Update(Time.deltaTime, Time.unscaledDeltaTime);
}
private void OnGUI()
@@ -246,16 +245,16 @@ namespace TEngine
GUISkin cachedGuiSkin = GUI.skin;
Matrix4x4 cachedMatrix = GUI.matrix;
GUI.skin = m_Skin;
GUI.matrix = Matrix4x4.Scale(new Vector3(m_WindowScale, m_WindowScale, 1f));
GUI.skin = skin;
GUI.matrix = Matrix4x4.Scale(new Vector3(_windowScale, _windowScale, 1f));
if (m_ShowFullWindow)
if (_showFullWindow)
{
m_WindowRect = GUILayout.Window(0, m_WindowRect, DrawWindow, "<b>DEBUGGER</b>");
_windowRect = GUILayout.Window(0, _windowRect, DrawWindow, "<b>DEBUGGER</b>");
}
else
{
m_IconRect = GUILayout.Window(0, m_IconRect, DrawDebuggerWindowIcon, "<b>DEBUGGER</b>");
_iconRect = GUILayout.Window(0, _iconRect, DrawDebuggerWindowIcon, "<b>DEBUGGER</b>");
}
GUI.matrix = cachedMatrix;
@@ -319,7 +318,7 @@ namespace TEngine
/// <param name="results">要获取的日志。</param>
public void GetRecentLogs(List<LogNode> results)
{
m_ConsoleWindow.GetRecentLogs(results);
_consoleWindow.GetRecentLogs(results);
}
/// <summary>
@@ -329,12 +328,12 @@ namespace TEngine
/// <param name="count">要获取最近日志的数量。</param>
public void GetRecentLogs(List<LogNode> results, int count)
{
m_ConsoleWindow.GetRecentLogs(results, count);
_consoleWindow.GetRecentLogs(results, count);
}
private void DrawWindow(int windowId)
{
GUI.DragWindow(m_DragRect);
GUI.DragWindow(_dragRect);
DrawDebuggerWindowGroup(_debuggerModule.DebuggerWindowRoot);
}
@@ -387,28 +386,28 @@ namespace TEngine
private void DrawDebuggerWindowIcon(int windowId)
{
GUI.DragWindow(m_DragRect);
GUI.DragWindow(_dragRect);
GUILayout.Space(5);
Color32 color = Color.white;
m_ConsoleWindow.RefreshCount();
if (m_ConsoleWindow.FatalCount > 0)
_consoleWindow.RefreshCount();
if (_consoleWindow.FatalCount > 0)
{
color = m_ConsoleWindow.GetLogStringColor(LogType.Exception);
color = _consoleWindow.GetLogStringColor(LogType.Exception);
}
else if (m_ConsoleWindow.ErrorCount > 0)
else if (_consoleWindow.ErrorCount > 0)
{
color = m_ConsoleWindow.GetLogStringColor(LogType.Error);
color = _consoleWindow.GetLogStringColor(LogType.Error);
}
else if (m_ConsoleWindow.WarningCount > 0)
else if (_consoleWindow.WarningCount > 0)
{
color = m_ConsoleWindow.GetLogStringColor(LogType.Warning);
color = _consoleWindow.GetLogStringColor(LogType.Warning);
}
else
{
color = m_ConsoleWindow.GetLogStringColor(LogType.Log);
color = _consoleWindow.GetLogStringColor(LogType.Log);
}
string title = Utility.Text.Format("<color=#{0:x2}{1:x2}{2:x2}{3:x2}><b>FPS: {4:F2}</b></color>", color.r, color.g, color.b, color.a, m_FpsCounter.CurrentFps);
string title = Utility.Text.Format("<color=#{0:x2}{1:x2}{2:x2}{3:x2}><b>FPS: {4:F2}</b></color>", color.r, color.g, color.b, color.a, _fpsCounter.CurrentFps);
if (GUILayout.Button(title, GUILayout.Width(100f), GUILayout.Height(40f)))
{
ShowFullWindow = true;

View File

@@ -25,69 +25,69 @@ namespace TEngine
private bool _lastFatalFilter = true;
[SerializeField]
private bool m_LockScroll = true;
private bool lockScroll = true;
[SerializeField]
private int m_MaxLine = 100;
private int maxLine = 100;
[SerializeField]
private bool m_InfoFilter = true;
private bool infoFilter = true;
[SerializeField]
private bool m_WarningFilter = true;
private bool warningFilter = true;
[SerializeField]
private bool m_ErrorFilter = true;
private bool errorFilter = true;
[SerializeField]
private bool m_FatalFilter = true;
private bool fatalFilter = true;
[SerializeField]
private Color32 m_InfoColor = Color.white;
private Color32 infoColor = Color.white;
[SerializeField]
private Color32 m_WarningColor = Color.yellow;
private Color32 warningColor = Color.yellow;
[SerializeField]
private Color32 m_ErrorColor = Color.red;
private Color32 errorColor = Color.red;
[SerializeField]
private Color32 m_FatalColor = new Color(0.7f, 0.2f, 0.2f);
private Color32 fatalColor = new Color(0.7f, 0.2f, 0.2f);
public bool LockScroll
{
get => m_LockScroll;
set => m_LockScroll = value;
get => lockScroll;
set => lockScroll = value;
}
public int MaxLine
{
get => m_MaxLine;
set => m_MaxLine = value;
get => maxLine;
set => maxLine = value;
}
public bool InfoFilter
{
get => m_InfoFilter;
set => m_InfoFilter = value;
get => infoFilter;
set => infoFilter = value;
}
public bool WarningFilter
{
get => m_WarningFilter;
set => m_WarningFilter = value;
get => warningFilter;
set => warningFilter = value;
}
public bool ErrorFilter
{
get => m_ErrorFilter;
set => m_ErrorFilter = value;
get => errorFilter;
set => errorFilter = value;
}
public bool FatalFilter
{
get => m_FatalFilter;
set => m_FatalFilter = value;
get => fatalFilter;
set => fatalFilter = value;
}
public int InfoCount => _infoCount;
@@ -100,36 +100,36 @@ namespace TEngine
public Color32 InfoColor
{
get => m_InfoColor;
set => m_InfoColor = value;
get => infoColor;
set => infoColor = value;
}
public Color32 WarningColor
{
get => m_WarningColor;
set => m_WarningColor = value;
get => warningColor;
set => warningColor = value;
}
public Color32 ErrorColor
{
get => m_ErrorColor;
set => m_ErrorColor = value;
get => errorColor;
set => errorColor = value;
}
public Color32 FatalColor
{
get => m_FatalColor;
set => m_FatalColor = value;
get => fatalColor;
set => fatalColor = value;
}
public void Initialize(params object[] args)
{
Application.logMessageReceived += OnLogMessageReceived;
m_LockScroll = _lastLockScroll = PlayerPrefs.GetInt("Debugger.Console.LockScroll", 1) == 1;
m_InfoFilter = _lastInfoFilter = PlayerPrefs.GetInt("Debugger.Console.InfoFilter", 1) == 1;
m_WarningFilter = _lastWarningFilter = PlayerPrefs.GetInt("Debugger.Console.WarningFilter", 1) == 1;
m_ErrorFilter = _lastErrorFilter = PlayerPrefs.GetInt("Debugger.Console.ErrorFilter", 1) == 1;
m_FatalFilter = _lastFatalFilter = PlayerPrefs.GetInt("Debugger.Console.FatalFilter", 1) == 1;
lockScroll = _lastLockScroll = PlayerPrefs.GetInt("Debugger.Console.LockScroll", 1) == 1;
infoFilter = _lastInfoFilter = PlayerPrefs.GetInt("Debugger.Console.InfoFilter", 1) == 1;
warningFilter = _lastWarningFilter = PlayerPrefs.GetInt("Debugger.Console.WarningFilter", 1) == 1;
errorFilter = _lastErrorFilter = PlayerPrefs.GetInt("Debugger.Console.ErrorFilter", 1) == 1;
fatalFilter = _lastFatalFilter = PlayerPrefs.GetInt("Debugger.Console.FatalFilter", 1) == 1;
}
public void Shutdown()
@@ -148,34 +148,34 @@ namespace TEngine
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
if (_lastLockScroll != m_LockScroll)
if (_lastLockScroll != lockScroll)
{
_lastLockScroll = m_LockScroll;
PlayerPrefs.SetInt("Debugger.Console.LockScroll", m_LockScroll ? 1 : 0);
_lastLockScroll = lockScroll;
PlayerPrefs.SetInt("Debugger.Console.LockScroll", lockScroll ? 1 : 0);
}
if (_lastInfoFilter != m_InfoFilter)
if (_lastInfoFilter != infoFilter)
{
_lastInfoFilter = m_InfoFilter;
PlayerPrefs.SetInt("Debugger.Console.InfoFilter", m_InfoFilter ? 1 : 0);
_lastInfoFilter = infoFilter;
PlayerPrefs.SetInt("Debugger.Console.InfoFilter", infoFilter ? 1 : 0);
}
if (_lastWarningFilter != m_WarningFilter)
if (_lastWarningFilter != warningFilter)
{
_lastWarningFilter = m_WarningFilter;
PlayerPrefs.SetInt("Debugger.Console.WarningFilter", m_WarningFilter ? 1 : 0);
_lastWarningFilter = warningFilter;
PlayerPrefs.SetInt("Debugger.Console.WarningFilter", warningFilter ? 1 : 0);
}
if (_lastErrorFilter != m_ErrorFilter)
if (_lastErrorFilter != errorFilter)
{
_lastErrorFilter = m_ErrorFilter;
PlayerPrefs.SetInt("Debugger.Console.ErrorFilter", m_ErrorFilter ? 1 : 0);
_lastErrorFilter = errorFilter;
PlayerPrefs.SetInt("Debugger.Console.ErrorFilter", errorFilter ? 1 : 0);
}
if (_lastFatalFilter != m_FatalFilter)
if (_lastFatalFilter != fatalFilter)
{
_lastFatalFilter = m_FatalFilter;
PlayerPrefs.SetInt("Debugger.Console.FatalFilter", m_FatalFilter ? 1 : 0);
_lastFatalFilter = fatalFilter;
PlayerPrefs.SetInt("Debugger.Console.FatalFilter", fatalFilter ? 1 : 0);
}
}
@@ -189,18 +189,18 @@ namespace TEngine
{
Clear();
}
m_LockScroll = GUILayout.Toggle(m_LockScroll, "Lock Scroll", GUILayout.Width(90f));
lockScroll = GUILayout.Toggle(lockScroll, "Lock Scroll", GUILayout.Width(90f));
GUILayout.FlexibleSpace();
m_InfoFilter = GUILayout.Toggle(m_InfoFilter, Utility.Text.Format("Info ({0})", _infoCount), GUILayout.Width(90f));
m_WarningFilter = GUILayout.Toggle(m_WarningFilter, Utility.Text.Format("Warning ({0})", _warningCount), GUILayout.Width(90f));
m_ErrorFilter = GUILayout.Toggle(m_ErrorFilter, Utility.Text.Format("Error ({0})", _errorCount), GUILayout.Width(90f));
m_FatalFilter = GUILayout.Toggle(m_FatalFilter, Utility.Text.Format("Fatal ({0})", _fatalCount), GUILayout.Width(90f));
infoFilter = GUILayout.Toggle(infoFilter, Utility.Text.Format("Info ({0})", _infoCount), GUILayout.Width(90f));
warningFilter = GUILayout.Toggle(warningFilter, Utility.Text.Format("Warning ({0})", _warningCount), GUILayout.Width(90f));
errorFilter = GUILayout.Toggle(errorFilter, Utility.Text.Format("Error ({0})", _errorCount), GUILayout.Width(90f));
fatalFilter = GUILayout.Toggle(fatalFilter, Utility.Text.Format("Fatal ({0})", _fatalCount), GUILayout.Width(90f));
}
GUILayout.EndHorizontal();
GUILayout.BeginVertical("box");
{
if (m_LockScroll)
if (lockScroll)
{
_logScrollPosition.y = float.MaxValue;
}
@@ -213,28 +213,28 @@ namespace TEngine
switch (logNode.LogType)
{
case LogType.Log:
if (!m_InfoFilter)
if (!infoFilter)
{
continue;
}
break;
case LogType.Warning:
if (!m_WarningFilter)
if (!warningFilter)
{
continue;
}
break;
case LogType.Error:
if (!m_ErrorFilter)
if (!errorFilter)
{
continue;
}
break;
case LogType.Exception:
if (!m_FatalFilter)
if (!fatalFilter)
{
continue;
}
@@ -367,7 +367,7 @@ namespace TEngine
}
_logNodes.Enqueue(LogNode.Create(logType, logMessage, stackTrace));
while (_logNodes.Count > m_MaxLine)
while (_logNodes.Count > maxLine)
{
MemoryPool.Release(_logNodes.Dequeue());
}
@@ -385,19 +385,19 @@ namespace TEngine
switch (logType)
{
case LogType.Log:
color = m_InfoColor;
color = infoColor;
break;
case LogType.Warning:
color = m_WarningColor;
color = warningColor;
break;
case LogType.Error:
color = m_ErrorColor;
color = errorColor;
break;
case LogType.Exception:
color = m_FatalColor;
color = fatalColor;
break;
}

View File

@@ -9,16 +9,9 @@ namespace TEngine
/// </summary>
private sealed class DebuggerWindowGroup : IDebuggerWindowGroup
{
private readonly List<KeyValuePair<string, IDebuggerWindow>> _debuggerWindows;
private int _selectedIndex;
private string[] _debuggerWindowNames;
public DebuggerWindowGroup()
{
_debuggerWindows = new List<KeyValuePair<string, IDebuggerWindow>>();
_selectedIndex = 0;
_debuggerWindowNames = null;
}
private readonly List<KeyValuePair<string, IDebuggerWindow>> _debuggerWindows = new();
private int _selectedIndex = 0;
private string[] _debuggerWindowNames = null;
/// <summary>
/// 获取调试器窗口数量。

View File

@@ -9,12 +9,12 @@ namespace TEngine
[StructLayout(LayoutKind.Auto)]
public struct ObjectInfo
{
private readonly string m_Name;
private readonly bool m_Locked;
private readonly bool m_CustomCanReleaseFlag;
private readonly int m_Priority;
private readonly DateTime m_LastUseTime;
private readonly int m_SpawnCount;
private readonly string _name;
private readonly bool _locked;
private readonly bool _customCanReleaseFlag;
private readonly int _priority;
private readonly DateTime _lastUseTime;
private readonly int _spawnCount;
/// <summary>
/// 初始化对象信息的新实例。
@@ -27,47 +27,47 @@ namespace TEngine
/// <param name="spawnCount">对象的获取计数。</param>
public ObjectInfo(string name, bool locked, bool customCanReleaseFlag, int priority, DateTime lastUseTime, int spawnCount)
{
m_Name = name;
m_Locked = locked;
m_CustomCanReleaseFlag = customCanReleaseFlag;
m_Priority = priority;
m_LastUseTime = lastUseTime;
m_SpawnCount = spawnCount;
_name = name;
_locked = locked;
_customCanReleaseFlag = customCanReleaseFlag;
_priority = priority;
_lastUseTime = lastUseTime;
_spawnCount = spawnCount;
}
/// <summary>
/// 获取对象名称。
/// </summary>
public string Name => m_Name;
public string Name => _name;
/// <summary>
/// 获取对象是否被加锁。
/// </summary>
public bool Locked => m_Locked;
public bool Locked => _locked;
/// <summary>
/// 获取对象自定义释放检查标记。
/// </summary>
public bool CustomCanReleaseFlag => m_CustomCanReleaseFlag;
public bool CustomCanReleaseFlag => _customCanReleaseFlag;
/// <summary>
/// 获取对象的优先级。
/// </summary>
public int Priority => m_Priority;
public int Priority => _priority;
/// <summary>
/// 获取对象上次使用时间。
/// </summary>
public DateTime LastUseTime => m_LastUseTime;
public DateTime LastUseTime => _lastUseTime;
/// <summary>
/// 获取对象是否正在使用。
/// </summary>
public bool IsInUse => m_SpawnCount > 0;
public bool IsInUse => _spawnCount > 0;
/// <summary>
/// 获取对象的获取计数。
/// </summary>
public int SpawnCount => m_SpawnCount;
public int SpawnCount => _spawnCount;
}
}

View File

@@ -7,7 +7,7 @@ namespace TEngine
/// </summary>
public abstract class ObjectPoolBase
{
private readonly string m_Name;
private readonly string _name;
/// <summary>
/// 初始化对象池基类的新实例。
@@ -23,18 +23,18 @@ namespace TEngine
/// <param name="name">对象池名称。</param>
public ObjectPoolBase(string name)
{
m_Name = name ?? string.Empty;
_name = name ?? string.Empty;
}
/// <summary>
/// 获取对象池名称。
/// </summary>
public string Name => m_Name;
public string Name => _name;
/// <summary>
/// 获取对象池完整名称。
/// </summary>
public string FullName => new TypeNamePair(ObjectType, m_Name).ToString();
public string FullName => new TypeNamePair(ObjectType, _name).ToString();
/// <summary>
/// 获取对象池对象类型。

View File

@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 内置资源清单
/// </summary>
public class BuildinFileManifest : ScriptableObject
{
[Serializable]
public class Element
{
public string PackageName;
public string FileName;
public string FileCRC32;
}
public List<Element> BuildinFiles = new List<Element>();
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: cc7dcf335fa34c189b66b9b8446f12e9
timeCreated: 1705979503

View File

@@ -5,9 +5,9 @@ namespace TEngine
/// </summary>
public sealed class LoadAssetCallbacks
{
private readonly LoadAssetSuccessCallback m_LoadAssetSuccessCallback;
private readonly LoadAssetFailureCallback m_LoadAssetFailureCallback;
private readonly LoadAssetUpdateCallback m_LoadAssetUpdateCallback;
private readonly LoadAssetSuccessCallback _loadAssetSuccessCallback;
private readonly LoadAssetFailureCallback _loadAssetFailureCallback;
private readonly LoadAssetUpdateCallback _loadAssetUpdateCallback;
/// <summary>
/// 初始化加载资源回调函数集的新实例。
@@ -51,9 +51,9 @@ namespace TEngine
throw new GameFrameworkException("Load asset success callback is invalid.");
}
m_LoadAssetSuccessCallback = loadAssetSuccessCallback;
m_LoadAssetFailureCallback = loadAssetFailureCallback;
m_LoadAssetUpdateCallback = loadAssetUpdateCallback;
_loadAssetSuccessCallback = loadAssetSuccessCallback;
_loadAssetFailureCallback = loadAssetFailureCallback;
_loadAssetUpdateCallback = loadAssetUpdateCallback;
}
/// <summary>
@@ -63,7 +63,7 @@ namespace TEngine
{
get
{
return m_LoadAssetSuccessCallback;
return _loadAssetSuccessCallback;
}
}
@@ -74,7 +74,7 @@ namespace TEngine
{
get
{
return m_LoadAssetFailureCallback;
return _loadAssetFailureCallback;
}
}
@@ -85,7 +85,7 @@ namespace TEngine
{
get
{
return m_LoadAssetUpdateCallback;
return _loadAssetUpdateCallback;
}
}
}

View File

@@ -5,9 +5,9 @@
/// </summary>
public sealed class LoadSceneCallbacks
{
private readonly LoadSceneSuccessCallback m_LoadSceneSuccessCallback;
private readonly LoadSceneFailureCallback m_LoadSceneFailureCallback;
private readonly LoadSceneUpdateCallback m_LoadSceneUpdateCallback;
private readonly LoadSceneSuccessCallback _loadSceneSuccessCallback;
private readonly LoadSceneFailureCallback _loadSceneFailureCallback;
private readonly LoadSceneUpdateCallback _loadSceneUpdateCallback;
/// <summary>
/// 初始化加载场景回调函数集的新实例。
@@ -51,9 +51,9 @@
throw new GameFrameworkException("Load scene success callback is invalid.");
}
m_LoadSceneSuccessCallback = loadSceneSuccessCallback;
m_LoadSceneFailureCallback = loadSceneFailureCallback;
m_LoadSceneUpdateCallback = loadSceneUpdateCallback;
_loadSceneSuccessCallback = loadSceneSuccessCallback;
_loadSceneFailureCallback = loadSceneFailureCallback;
_loadSceneUpdateCallback = loadSceneUpdateCallback;
}
/// <summary>
@@ -63,7 +63,7 @@
{
get
{
return m_LoadSceneSuccessCallback;
return _loadSceneSuccessCallback;
}
}
@@ -74,7 +74,7 @@
{
get
{
return m_LoadSceneFailureCallback;
return _loadSceneFailureCallback;
}
}
@@ -85,7 +85,7 @@
{
get
{
return m_LoadSceneUpdateCallback;
return _loadSceneUpdateCallback;
}
}
}

View File

@@ -5,8 +5,8 @@
/// </summary>
public sealed class UnloadSceneCallbacks
{
private readonly UnloadSceneSuccessCallback m_UnloadSceneSuccessCallback;
private readonly UnloadSceneFailureCallback m_UnloadSceneFailureCallback;
private readonly UnloadSceneSuccessCallback _unloadSceneSuccessCallback;
private readonly UnloadSceneFailureCallback _unloadSceneFailureCallback;
/// <summary>
/// 初始化卸载场景回调函数集的新实例。
@@ -29,8 +29,8 @@
throw new GameFrameworkException("Unload scene success callback is invalid.");
}
m_UnloadSceneSuccessCallback = unloadSceneSuccessCallback;
m_UnloadSceneFailureCallback = unloadSceneFailureCallback;
_unloadSceneSuccessCallback = unloadSceneSuccessCallback;
_unloadSceneFailureCallback = unloadSceneFailureCallback;
}
/// <summary>
@@ -40,7 +40,7 @@
{
get
{
return m_UnloadSceneSuccessCallback;
return _unloadSceneSuccessCallback;
}
}
@@ -51,7 +51,7 @@
{
get
{
return m_UnloadSceneFailureCallback;
return _unloadSceneFailureCallback;
}
}
}

View File

@@ -20,86 +20,86 @@ namespace TEngine
#if ODIN_INSPECTOR
[ShowInInspector]
#endif
private SetType setType;
private SetType _setType;
#if ODIN_INSPECTOR
[ShowInInspector]
#endif
private Image m_Image;
private Image _image;
#if ODIN_INSPECTOR
[ShowInInspector]
#endif
private SpriteRenderer m_SpriteRenderer;
private SpriteRenderer _spriteRenderer;
#if ODIN_INSPECTOR
[ShowInInspector]
#endif
private Sprite Sprite;
private Sprite _sprite;
public string Location { get; private set; }
private bool m_SetNativeSize = false;
private bool _setNativeSize = false;
public void SetAsset(Object asset)
{
Sprite = (Sprite)asset;
_sprite = (Sprite)asset;
if (m_Image != null)
if (_image != null)
{
m_Image.sprite = Sprite;
if (m_SetNativeSize)
_image.sprite = _sprite;
if (_setNativeSize)
{
m_Image.SetNativeSize();
_image.SetNativeSize();
}
}
else if (m_SpriteRenderer != null)
else if (_spriteRenderer != null)
{
m_SpriteRenderer.sprite = Sprite;
_spriteRenderer.sprite = _sprite;
}
}
public bool IsCanRelease()
{
if (setType == SetType.Image)
if (_setType == SetType.Image)
{
return m_Image == null || m_Image.sprite == null ||
(Sprite != null && m_Image.sprite != Sprite);
return _image == null || _image.sprite == null ||
(_sprite != null && _image.sprite != _sprite);
}
else if (setType == SetType.SpriteRender)
else if (_setType == SetType.SpriteRender)
{
return m_SpriteRenderer == null || m_SpriteRenderer.sprite == null ||
(Sprite != null && m_SpriteRenderer.sprite != Sprite);
return _spriteRenderer == null || _spriteRenderer.sprite == null ||
(_sprite != null && _spriteRenderer.sprite != _sprite);
}
return true;
}
public void Clear()
{
m_SpriteRenderer = null;
m_Image = null;
_spriteRenderer = null;
_image = null;
Location = null;
Sprite = null;
setType = SetType.None;
m_SetNativeSize = false;
_sprite = null;
_setType = SetType.None;
_setNativeSize = false;
}
public static SetSpriteObject Create(Image image, string location, bool setNativeSize = false)
{
SetSpriteObject item = MemoryPool.Acquire<SetSpriteObject>();
item.m_Image = image;
item.m_SetNativeSize = setNativeSize;
item._image = image;
item._setNativeSize = setNativeSize;
item.Location = location;
item.setType = SetType.Image;
item._setType = SetType.Image;
return item;
}
public static SetSpriteObject Create(SpriteRenderer spriteRenderer, string location)
{
SetSpriteObject item = MemoryPool.Acquire<SetSpriteObject>();
item.m_SpriteRenderer = spriteRenderer;
item._spriteRenderer = spriteRenderer;
item.Location = location;
item.setType = SetType.SpriteRender;
item._setType = SetType.SpriteRender;
return item;
}
}

View File

@@ -7,32 +7,32 @@ namespace TEngine
/// <summary>
/// 资源组件。
/// </summary>
private static IResourceModule m_ResourceModule;
private static IResourceModule _resourceModule;
private LoadAssetCallbacks m_LoadAssetCallbacks;
private LoadAssetCallbacks _loadAssetCallbacks;
public static IResourceModule ResourceModule => m_ResourceModule;
public static IResourceModule ResourceModule => _resourceModule;
private void InitializedResources()
{
m_ResourceModule = ModuleSystem.GetModule<IResourceModule>();
m_LoadAssetCallbacks = new LoadAssetCallbacks(OnLoadAssetSuccess, OnLoadAssetFailure);
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
_loadAssetCallbacks = new LoadAssetCallbacks(OnLoadAssetSuccess, OnLoadAssetFailure);
}
private void OnLoadAssetFailure(string assetName, LoadResourceStatus status, string errormessage, object userdata)
{
m_AssetLoadingList.Remove(assetName);
_assetLoadingList.Remove(assetName);
Log.Error("Can not load asset from '{1}' with error message '{2}'.", assetName, errormessage);
}
private void OnLoadAssetSuccess(string assetName, object asset, float duration, object userdata)
{
m_AssetLoadingList.Remove(assetName);
_assetLoadingList.Remove(assetName);
ISetAssetObject setAssetObject = (ISetAssetObject)userdata;
UnityEngine.Object assetObject = asset as UnityEngine.Object;
if (assetObject != null)
{
m_AssetItemPool.Register(AssetItemObject.Create(setAssetObject.Location, assetObject), true);
_assetItemPool.Register(AssetItemObject.Create(setAssetObject.Location, assetObject), true);
SetAsset(setAssetObject, assetObject);
}
else
@@ -49,15 +49,15 @@ namespace TEngine
{
await TryWaitingLoading(setAssetObject.Location);
if (m_AssetItemPool.CanSpawn(setAssetObject.Location))
if (_assetItemPool.CanSpawn(setAssetObject.Location))
{
var assetObject = (T)m_AssetItemPool.Spawn(setAssetObject.Location).Target;
var assetObject = (T)_assetItemPool.Spawn(setAssetObject.Location).Target;
SetAsset(setAssetObject, assetObject);
}
else
{
m_AssetLoadingList.Add(setAssetObject.Location);
m_ResourceModule.LoadAssetAsync(setAssetObject.Location, 0, m_LoadAssetCallbacks, setAssetObject);
_assetLoadingList.Add(setAssetObject.Location);
_resourceModule.LoadAssetAsync(setAssetObject.Location, 0, _loadAssetCallbacks, setAssetObject);
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.Serialization;
using Object = UnityEngine.Object;
#if ODIN_INSPECTOR
using Sirenix.OdinInspector;
@@ -18,24 +19,24 @@ namespace TEngine
{
public static ResourceExtComponent Instance { private set; get; }
private readonly TimeoutController m_TimeoutController = new TimeoutController();
private readonly TimeoutController _timeoutController = new TimeoutController();
/// <summary>
/// 正在加载的资源列表。
/// </summary>
private readonly HashSet<string> m_AssetLoadingList = new HashSet<string>();
private readonly HashSet<string> _assetLoadingList = new HashSet<string>();
/// <summary>
/// 检查是否可以释放间隔
/// </summary>
[SerializeField] private float m_CheckCanReleaseInterval = 30f;
[SerializeField] private float checkCanReleaseInterval = 30f;
private float m_CheckCanReleaseTime = 0.0f;
private float _checkCanReleaseTime = 0.0f;
/// <summary>
/// 对象池自动释放时间间隔
/// </summary>
[SerializeField] private float m_AutoReleaseInterval = 60f;
[SerializeField] private float autoReleaseInterval = 60f;
/// <summary>
/// 保存加载的图片对象
@@ -43,19 +44,19 @@ namespace TEngine
#if ODIN_INSPECTOR
[ShowInInspector]
#endif
private LinkedList<LoadAssetObject> m_LoadAssetObjectsLinkedList;
private LinkedList<LoadAssetObject> _loadAssetObjectsLinkedList;
/// <summary>
/// 散图集合对象池
/// </summary>
private IObjectPool<AssetItemObject> m_AssetItemPool;
private IObjectPool<AssetItemObject> _assetItemPool;
#if UNITY_EDITOR
public LinkedList<LoadAssetObject> LoadAssetObjectsLinkedList
{
get => m_LoadAssetObjectsLinkedList;
set => m_LoadAssetObjectsLinkedList = value;
get => _loadAssetObjectsLinkedList;
set => _loadAssetObjectsLinkedList = value;
}
#endif
private IEnumerator Start()
@@ -63,18 +64,18 @@ namespace TEngine
Instance = this;
yield return new WaitForEndOfFrame();
IObjectPoolModule objectPoolComponent = ModuleSystem.GetModule<IObjectPoolModule>();
m_AssetItemPool = objectPoolComponent.CreateMultiSpawnObjectPool<AssetItemObject>(
_assetItemPool = objectPoolComponent.CreateMultiSpawnObjectPool<AssetItemObject>(
"SetAssetPool",
m_AutoReleaseInterval, 16, 60, 0);
m_LoadAssetObjectsLinkedList = new LinkedList<LoadAssetObject>();
autoReleaseInterval, 16, 60, 0);
_loadAssetObjectsLinkedList = new LinkedList<LoadAssetObject>();
InitializedResources();
}
private void Update()
{
m_CheckCanReleaseTime += Time.unscaledDeltaTime;
if (m_CheckCanReleaseTime < (double)m_CheckCanReleaseInterval)
_checkCanReleaseTime += Time.unscaledDeltaTime;
if (_checkCanReleaseTime < (double)checkCanReleaseInterval)
{
return;
}
@@ -90,45 +91,45 @@ namespace TEngine
#endif
public void ReleaseUnused()
{
if (m_LoadAssetObjectsLinkedList == null)
if (_loadAssetObjectsLinkedList == null)
{
return;
}
LinkedListNode<LoadAssetObject> current = m_LoadAssetObjectsLinkedList.First;
LinkedListNode<LoadAssetObject> current = _loadAssetObjectsLinkedList.First;
while (current != null)
{
var next = current.Next;
if (current.Value.AssetObject.IsCanRelease())
{
m_AssetItemPool.Unspawn(current.Value.AssetTarget);
_assetItemPool.Unspawn(current.Value.AssetTarget);
MemoryPool.Release(current.Value.AssetObject);
m_LoadAssetObjectsLinkedList.Remove(current);
_loadAssetObjectsLinkedList.Remove(current);
}
current = next;
}
m_CheckCanReleaseTime = 0f;
_checkCanReleaseTime = 0f;
}
private void SetAsset(ISetAssetObject setAssetObject, Object assetObject)
{
m_LoadAssetObjectsLinkedList.AddLast(new LoadAssetObject(setAssetObject, assetObject));
_loadAssetObjectsLinkedList.AddLast(new LoadAssetObject(setAssetObject, assetObject));
setAssetObject.SetAsset(assetObject);
}
private async UniTask TryWaitingLoading(string assetObjectKey)
{
if (m_AssetLoadingList.Contains(assetObjectKey))
if (_assetLoadingList.Contains(assetObjectKey))
{
try
{
await UniTask.WaitUntil(
() => !m_AssetLoadingList.Contains(assetObjectKey))
() => !_assetLoadingList.Contains(assetObjectKey))
#if UNITY_EDITOR
.AttachExternalCancellation(m_TimeoutController.Timeout(TimeSpan.FromSeconds(60)));
m_TimeoutController.Reset();
.AttachExternalCancellation(_timeoutController.Timeout(TimeSpan.FromSeconds(60)));
_timeoutController.Reset();
#else
;
#endif
@@ -136,7 +137,7 @@ namespace TEngine
}
catch (OperationCanceledException ex)
{
if (m_TimeoutController.IsTimeout())
if (_timeoutController.IsTimeout())
{
Log.Error($"LoadAssetAsync Waiting {assetObjectKey} timeout. reason:{ex.Message}");
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
using Object = UnityEngine.Object;
namespace TEngine
@@ -21,9 +22,9 @@ namespace TEngine
public sealed class AssetsReference : MonoBehaviour
{
[SerializeField] private GameObject _sourceGameObject;
[SerializeField] private GameObject sourceGameObject;
[SerializeField] private List<AssetsRefInfo> _refAssetInfoList;
[SerializeField] private List<AssetsRefInfo> refAssetInfoList;
private IResourceModule _resourceModule;
@@ -39,9 +40,9 @@ namespace TEngine
throw new GameFrameworkException($"resourceModule is null.");
}
if (_sourceGameObject != null)
if (sourceGameObject != null)
{
_resourceModule.UnloadAsset(_sourceGameObject);
_resourceModule.UnloadAsset(sourceGameObject);
}
ReleaseRefAssetInfoList();
@@ -49,14 +50,14 @@ namespace TEngine
private void ReleaseRefAssetInfoList()
{
if (_refAssetInfoList != null)
if (refAssetInfoList != null)
{
foreach (var refInfo in _refAssetInfoList)
foreach (var refInfo in refAssetInfoList)
{
_resourceModule.UnloadAsset(refInfo.refAsset);
}
_refAssetInfoList.Clear();
refAssetInfoList.Clear();
}
}
@@ -73,7 +74,7 @@ namespace TEngine
}
_resourceModule = resourceModule;
_sourceGameObject = source;
sourceGameObject = source;
return this;
}
@@ -85,11 +86,11 @@ namespace TEngine
}
_resourceModule = resourceModule;
if (_refAssetInfoList == null)
if (refAssetInfoList == null)
{
_refAssetInfoList = new List<AssetsRefInfo>();
refAssetInfoList = new List<AssetsRefInfo>();
}
_refAssetInfoList.Add(new AssetsRefInfo(source));
refAssetInfoList.Add(new AssetsRefInfo(source));
return this;
}

View File

@@ -10,14 +10,8 @@ namespace TEngine
/// </summary>
private sealed class AssetObject : ObjectBase
{
private AssetHandle m_AssetHandle;
private ResourceModule m_ResourceManager;
public AssetObject()
{
m_AssetHandle = null;
}
private AssetHandle _assetHandle = null;
private ResourceModule _resourceModule;
public static AssetObject Create(string name, object target, object assetHandle, ResourceModule resourceModule)
{
@@ -33,15 +27,15 @@ namespace TEngine
AssetObject assetObject = MemoryPool.Acquire<AssetObject>();
assetObject.Initialize(name, target);
assetObject.m_AssetHandle = (AssetHandle)assetHandle;
assetObject.m_ResourceManager = resourceModule;
assetObject._assetHandle = (AssetHandle)assetHandle;
assetObject._resourceModule = resourceModule;
return assetObject;
}
public override void Clear()
{
base.Clear();
m_AssetHandle = null;
_assetHandle = null;
}
protected internal override void OnUnspawn()
@@ -53,7 +47,7 @@ namespace TEngine
{
if (!isShutdown)
{
AssetHandle handle = m_AssetHandle;
AssetHandle handle = _assetHandle;
if (handle is { IsValid: true })
{
handle.Dispose();

View File

@@ -2,15 +2,15 @@
{
internal partial class ResourceModule
{
private IObjectPool<AssetObject> m_AssetPool;
private IObjectPool<AssetObject> _assetPool;
/// <summary>
/// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
/// </summary>
public float AssetAutoReleaseInterval
{
get => m_AssetPool.AutoReleaseInterval;
set => m_AssetPool.AutoReleaseInterval = value;
get => _assetPool.AutoReleaseInterval;
set => _assetPool.AutoReleaseInterval = value;
}
/// <summary>
@@ -18,8 +18,8 @@
/// </summary>
public int AssetCapacity
{
get => m_AssetPool.Capacity;
set => m_AssetPool.Capacity = value;
get => _assetPool.Capacity;
set => _assetPool.Capacity = value;
}
/// <summary>
@@ -27,8 +27,8 @@
/// </summary>
public float AssetExpireTime
{
get => m_AssetPool.ExpireTime;
set => m_AssetPool.ExpireTime = value;
get => _assetPool.ExpireTime;
set => _assetPool.ExpireTime = value;
}
/// <summary>
@@ -36,8 +36,8 @@
/// </summary>
public int AssetPriority
{
get => m_AssetPool.Priority;
set => m_AssetPool.Priority = value;
get => _assetPool.Priority;
set => _assetPool.Priority = value;
}
/// <summary>
@@ -46,9 +46,9 @@
/// <param name="asset">要卸载的资源。</param>
public void UnloadAsset(object asset)
{
if (m_AssetPool != null)
if (_assetPool != null)
{
m_AssetPool.Unspawn(asset);
_assetPool.Unspawn(asset);
}
}
@@ -62,7 +62,7 @@
{
throw new GameFrameworkException("Object pool manager is invalid.");
}
m_AssetPool = objectPoolModule.CreateMultiSpawnObjectPool<AssetObject>("Asset Pool");
_assetPool = objectPoolModule.CreateMultiSpawnObjectPool<AssetObject>("Asset Pool");
}
}
}

View File

@@ -49,19 +49,19 @@ namespace TEngine
public string FallbackHostServerURL { get; set; }
private string m_ApplicableGameVersion;
private string _applicableGameVersion;
private int m_InternalResourceVersion;
private int _internalResourceVersion;
/// <summary>
/// 获取当前资源适用的游戏版本号。
/// </summary>
public string ApplicableGameVersion => m_ApplicableGameVersion;
public string ApplicableGameVersion => _applicableGameVersion;
/// <summary>
/// 获取当前内部资源版本号。
/// </summary>
public int InternalResourceVersion => m_InternalResourceVersion;
public int InternalResourceVersion => _internalResourceVersion;
/// <summary>
/// 当前最新的包裹版本。
@@ -318,10 +318,10 @@ namespace TEngine
public void OnLowMemory()
{
Log.Warning("Low memory reported...");
m_ForceUnloadUnusedAssetsAction?.Invoke(true);
_forceUnloadUnusedAssetsAction?.Invoke(true);
}
private Action<bool> m_ForceUnloadUnusedAssetsAction;
private Action<bool> _forceUnloadUnusedAssetsAction;
/// <summary>
/// 低内存回调保护。
@@ -329,7 +329,7 @@ namespace TEngine
/// <param name="action">低内存行为。</param>
public void SetForceUnloadUnusedAssetsAction(Action<bool> action)
{
m_ForceUnloadUnusedAssetsAction = action;
_forceUnloadUnusedAssetsAction = action;
}
/// <summary>
@@ -337,7 +337,7 @@ namespace TEngine
/// </summary>
public void UnloadUnusedAssets()
{
m_AssetPool.ReleaseAllUnused();
_assetPool.ReleaseAllUnused();
foreach (var package in PackageMap.Values)
{
if (package is { InitializeStatus: EOperationStatus.Succeed })
@@ -369,7 +369,7 @@ namespace TEngine
public void ForceUnloadUnusedAssets(bool performGCCollect)
{
m_ForceUnloadUnusedAssetsAction?.Invoke(performGCCollect);
_forceUnloadUnusedAssetsAction?.Invoke(performGCCollect);
}
#region Public Methods
@@ -623,7 +623,7 @@ namespace TEngine
}
string assetObjectKey = GetCacheKey(location, packageName);
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
return assetObject.Target as T;
@@ -634,7 +634,7 @@ namespace TEngine
T ret = handle.AssetObject as T;
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
return ret;
}
@@ -647,7 +647,7 @@ namespace TEngine
}
string assetObjectKey = GetCacheKey(location, packageName);
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
return AssetsReference.Instantiate(assetObject.Target as GameObject, parent, this).gameObject;
@@ -658,7 +658,7 @@ namespace TEngine
GameObject gameObject = AssetsReference.Instantiate(handle.AssetObject as GameObject, parent, this).gameObject;
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
return gameObject;
}
@@ -687,7 +687,7 @@ namespace TEngine
await TryWaitingLoading(assetObjectKey);
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
await UniTask.Yield();
@@ -706,7 +706,7 @@ namespace TEngine
if (assetHandle.AssetObject != null)
{
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
callback?.Invoke(assetObject.Target as T);
}
@@ -748,7 +748,7 @@ namespace TEngine
await TryWaitingLoading(assetObjectKey);
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
await UniTask.Yield();
@@ -768,7 +768,7 @@ namespace TEngine
}
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
_assetLoadingList.Remove(assetObjectKey);
@@ -786,7 +786,7 @@ namespace TEngine
await TryWaitingLoading(assetObjectKey);
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
await UniTask.Yield();
@@ -808,7 +808,7 @@ namespace TEngine
GameObject gameObject = AssetsReference.Instantiate(handle.AssetObject as GameObject, parent, this).gameObject;
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
_assetLoadingList.Remove(assetObjectKey);
@@ -844,7 +844,7 @@ namespace TEngine
float duration = Time.time;
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
await UniTask.Yield();
@@ -895,7 +895,7 @@ namespace TEngine
else
{
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
_assetLoadingList.Remove(assetObjectKey);
@@ -934,7 +934,7 @@ namespace TEngine
float duration = Time.time;
AssetObject assetObject = m_AssetPool.Spawn(assetObjectKey);
AssetObject assetObject = _assetPool.Spawn(assetObjectKey);
if (assetObject != null)
{
await UniTask.Yield();
@@ -985,7 +985,7 @@ namespace TEngine
else
{
assetObject = AssetObject.Create(assetObjectKey, handle.AssetObject, handle, this);
m_AssetPool.Register(assetObject, true);
_assetPool.Register(assetObject, true);
_assetLoadingList.Remove(assetObjectKey);

View File

@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
using YooAsset;
namespace TEngine
@@ -14,23 +15,23 @@ namespace TEngine
private const int DefaultPriority = 0;
private IResourceModule m_ResourceModule;
private IResourceModule _resourceModule;
private bool m_ForceUnloadUnusedAssets = false;
private bool _forceUnloadUnusedAssets = false;
private bool m_PreorderUnloadUnusedAssets = false;
private bool _preorderUnloadUnusedAssets = false;
private bool m_PerformGCCollect = false;
private bool _performGCCollect = false;
private AsyncOperation m_AsyncOperation = null;
private AsyncOperation _asyncOperation = null;
private float m_LastUnloadUnusedAssetsOperationElapseSeconds = 0f;
private float _lastUnloadUnusedAssetsOperationElapseSeconds = 0f;
[SerializeField] private float m_MinUnloadUnusedAssetsInterval = 60f;
[SerializeField] private float minUnloadUnusedAssetsInterval = 60f;
[SerializeField] private float m_MaxUnloadUnusedAssetsInterval = 300f;
[SerializeField] private float maxUnloadUnusedAssetsInterval = 300f;
[SerializeField] private bool m_UseSystemUnloadUnusedAssets = true;
[SerializeField] private bool useSystemUnloadUnusedAssets = true;
/// <summary>
/// 当前最新的包裹版本。
@@ -87,54 +88,54 @@ namespace TEngine
/// <summary>
/// 是否支持边玩边下载。
/// </summary>
[SerializeField] private bool m_UpdatableWhilePlaying = false;
[SerializeField] private bool updatableWhilePlaying = false;
/// <summary>
/// 是否支持边玩边下载。
/// </summary>
public bool UpdatableWhilePlaying => m_UpdatableWhilePlaying;
public bool UpdatableWhilePlaying => updatableWhilePlaying;
/// <summary>
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
/// </summary>
[SerializeField] public long Milliseconds = 30;
[SerializeField] public long milliseconds = 30;
public int m_DownloadingMaxNum = 10;
public int downloadingMaxNum = 10;
/// <summary>
/// 获取或设置同时最大下载数目。
/// </summary>
public int DownloadingMaxNum
{
get => m_DownloadingMaxNum;
set => m_DownloadingMaxNum = value;
get => downloadingMaxNum;
set => downloadingMaxNum = value;
}
public int m_FailedTryAgain = 3;
[SerializeField] public int failedTryAgain = 3;
public int FailedTryAgain
{
get => m_FailedTryAgain;
set => m_FailedTryAgain = value;
get => failedTryAgain;
set => failedTryAgain = value;
}
/// <summary>
/// 获取当前资源适用的游戏版本号。
/// </summary>
public string ApplicableGameVersion => m_ResourceModule.ApplicableGameVersion;
public string ApplicableGameVersion => _resourceModule.ApplicableGameVersion;
/// <summary>
/// 获取当前内部资源版本号。
/// </summary>
public int InternalResourceVersion => m_ResourceModule.InternalResourceVersion;
public int InternalResourceVersion => _resourceModule.InternalResourceVersion;
/// <summary>
/// 获取或设置无用资源释放的最小间隔时间,以秒为单位。
/// </summary>
public float MinUnloadUnusedAssetsInterval
{
get => m_MinUnloadUnusedAssetsInterval;
set => m_MinUnloadUnusedAssetsInterval = value;
get => minUnloadUnusedAssetsInterval;
set => minUnloadUnusedAssetsInterval = value;
}
/// <summary>
@@ -142,8 +143,8 @@ namespace TEngine
/// </summary>
public float MaxUnloadUnusedAssetsInterval
{
get => m_MaxUnloadUnusedAssetsInterval;
set => m_MaxUnloadUnusedAssetsInterval = value;
get => maxUnloadUnusedAssetsInterval;
set => maxUnloadUnusedAssetsInterval = value;
}
/// <summary>
@@ -151,30 +152,30 @@ namespace TEngine
/// </summary>
public bool UseSystemUnloadUnusedAssets
{
get => m_UseSystemUnloadUnusedAssets;
set => m_UseSystemUnloadUnusedAssets = value;
get => useSystemUnloadUnusedAssets;
set => useSystemUnloadUnusedAssets = value;
}
/// <summary>
/// 获取无用资源释放的等待时长,以秒为单位。
/// </summary>
public float LastUnloadUnusedAssetsOperationElapseSeconds => m_LastUnloadUnusedAssetsOperationElapseSeconds;
public float LastUnloadUnusedAssetsOperationElapseSeconds => _lastUnloadUnusedAssetsOperationElapseSeconds;
[SerializeField] private float m_AssetAutoReleaseInterval = 60f;
[SerializeField] private float assetAutoReleaseInterval = 60f;
[SerializeField] private int m_AssetCapacity = 64;
[SerializeField] private int assetCapacity = 64;
[SerializeField] private float m_AssetExpireTime = 60f;
[SerializeField] private float assetExpireTime = 60f;
[SerializeField] private int m_AssetPriority = 0;
[SerializeField] private int assetPriority = 0;
/// <summary>
/// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
/// </summary>
public float AssetAutoReleaseInterval
{
get => m_ResourceModule.AssetAutoReleaseInterval;
set => m_ResourceModule.AssetAutoReleaseInterval = m_AssetAutoReleaseInterval = value;
get => _resourceModule.AssetAutoReleaseInterval;
set => _resourceModule.AssetAutoReleaseInterval = assetAutoReleaseInterval = value;
}
/// <summary>
@@ -182,8 +183,8 @@ namespace TEngine
/// </summary>
public int AssetCapacity
{
get => m_ResourceModule.AssetCapacity;
set => m_ResourceModule.AssetCapacity = m_AssetCapacity = value;
get => _resourceModule.AssetCapacity;
set => _resourceModule.AssetCapacity = assetCapacity = value;
}
/// <summary>
@@ -191,8 +192,8 @@ namespace TEngine
/// </summary>
public float AssetExpireTime
{
get => m_ResourceModule.AssetExpireTime;
set => m_ResourceModule.AssetExpireTime = m_AssetExpireTime = value;
get => _resourceModule.AssetExpireTime;
set => _resourceModule.AssetExpireTime = assetExpireTime = value;
}
/// <summary>
@@ -200,16 +201,16 @@ namespace TEngine
/// </summary>
public int AssetPriority
{
get => m_ResourceModule.AssetPriority;
set => m_ResourceModule.AssetPriority = m_AssetPriority = value;
get => _resourceModule.AssetPriority;
set => _resourceModule.AssetPriority = assetPriority = value;
}
#endregion
private void Start()
{
m_ResourceModule = ModuleSystem.GetModule<IResourceModule>();
if (m_ResourceModule == null)
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
if (_resourceModule == null)
{
Log.Fatal("Resource module is invalid.");
return;
@@ -223,20 +224,20 @@ namespace TEngine
#endif
}
m_ResourceModule.DefaultPackageName = PackageName;
m_ResourceModule.PlayMode = PlayMode;
m_ResourceModule.Milliseconds = Milliseconds;
m_ResourceModule.HostServerURL = Settings.UpdateSetting.GetResDownLoadPath();
m_ResourceModule.FallbackHostServerURL = Settings.UpdateSetting.GetFallbackResDownLoadPath();
m_ResourceModule.DownloadingMaxNum = DownloadingMaxNum;
m_ResourceModule.FailedTryAgain = FailedTryAgain;
m_ResourceModule.UpdatableWhilePlaying = UpdatableWhilePlaying;
m_ResourceModule.Initialize();
m_ResourceModule.AssetAutoReleaseInterval = m_AssetAutoReleaseInterval;
m_ResourceModule.AssetCapacity = m_AssetCapacity;
m_ResourceModule.AssetExpireTime = m_AssetExpireTime;
m_ResourceModule.AssetPriority = m_AssetPriority;
m_ResourceModule.SetForceUnloadUnusedAssetsAction(ForceUnloadUnusedAssets);
_resourceModule.DefaultPackageName = PackageName;
_resourceModule.PlayMode = PlayMode;
_resourceModule.Milliseconds = milliseconds;
_resourceModule.HostServerURL = Settings.UpdateSetting.GetResDownLoadPath();
_resourceModule.FallbackHostServerURL = Settings.UpdateSetting.GetFallbackResDownLoadPath();
_resourceModule.DownloadingMaxNum = DownloadingMaxNum;
_resourceModule.FailedTryAgain = FailedTryAgain;
_resourceModule.UpdatableWhilePlaying = UpdatableWhilePlaying;
_resourceModule.Initialize();
_resourceModule.AssetAutoReleaseInterval = assetAutoReleaseInterval;
_resourceModule.AssetCapacity = assetCapacity;
_resourceModule.AssetExpireTime = assetExpireTime;
_resourceModule.AssetPriority = assetPriority;
_resourceModule.SetForceUnloadUnusedAssetsAction(ForceUnloadUnusedAssets);
Log.Info($"ResourceModule Run Mode{PlayMode}");
}
@@ -248,38 +249,38 @@ namespace TEngine
/// <param name="performGCCollect">是否使用垃圾回收。</param>
public void ForceUnloadUnusedAssets(bool performGCCollect)
{
m_ForceUnloadUnusedAssets = true;
_forceUnloadUnusedAssets = true;
if (performGCCollect)
{
m_PerformGCCollect = true;
_performGCCollect = true;
}
}
private void Update()
{
m_LastUnloadUnusedAssetsOperationElapseSeconds += Time.unscaledDeltaTime;
if (m_AsyncOperation == null && (m_ForceUnloadUnusedAssets || m_LastUnloadUnusedAssetsOperationElapseSeconds >= m_MaxUnloadUnusedAssetsInterval ||
m_PreorderUnloadUnusedAssets && m_LastUnloadUnusedAssetsOperationElapseSeconds >= m_MinUnloadUnusedAssetsInterval))
_lastUnloadUnusedAssetsOperationElapseSeconds += Time.unscaledDeltaTime;
if (_asyncOperation == null && (_forceUnloadUnusedAssets || _lastUnloadUnusedAssetsOperationElapseSeconds >= maxUnloadUnusedAssetsInterval ||
_preorderUnloadUnusedAssets && _lastUnloadUnusedAssetsOperationElapseSeconds >= minUnloadUnusedAssetsInterval))
{
Log.Info("Unload unused assets...");
m_ForceUnloadUnusedAssets = false;
m_PreorderUnloadUnusedAssets = false;
m_LastUnloadUnusedAssetsOperationElapseSeconds = 0f;
m_AsyncOperation = Resources.UnloadUnusedAssets();
if (m_UseSystemUnloadUnusedAssets)
_forceUnloadUnusedAssets = false;
_preorderUnloadUnusedAssets = false;
_lastUnloadUnusedAssetsOperationElapseSeconds = 0f;
_asyncOperation = Resources.UnloadUnusedAssets();
if (useSystemUnloadUnusedAssets)
{
m_ResourceModule.UnloadUnusedAssets();
_resourceModule.UnloadUnusedAssets();
}
}
if (m_AsyncOperation is { isDone: true })
if (_asyncOperation is { isDone: true })
{
m_AsyncOperation = null;
if (m_PerformGCCollect)
_asyncOperation = null;
if (_performGCCollect)
{
Log.Info("GC.Collect...");
m_PerformGCCollect = false;
_performGCCollect = false;
GC.Collect();
}
}

View File

@@ -9,41 +9,33 @@ namespace TEngine
[DisallowMultipleComponent]
public sealed class RootModule : MonoBehaviour
{
private const int DefaultDpi = 96; // default windows dpi
private const int DefaultDpi = 96; // default windows dpi
private float m_GameSpeedBeforePause = 1f;
private float _gameSpeedBeforePause = 1f;
[SerializeField]
private Language m_EditorLanguage = Language.Unspecified;
[SerializeField] private Language editorLanguage = Language.Unspecified;
[SerializeField]
private string m_TextHelperTypeName = "TEngine.DefaultTextHelper";
[SerializeField]
private string m_LogHelperTypeName = "TEngine.DefaultLogHelper";
[SerializeField] private string textHelperTypeName = "TEngine.DefaultTextHelper";
[SerializeField]
private string m_JsonHelperTypeName = "TEngine.DefaultJsonHelper";
[SerializeField] private string logHelperTypeName = "TEngine.DefaultLogHelper";
[SerializeField]
private int m_FrameRate = 120;
[SerializeField] private string jsonHelperTypeName = "TEngine.DefaultJsonHelper";
[SerializeField]
private float m_GameSpeed = 1f;
[SerializeField] private int frameRate = 120;
[SerializeField]
private bool m_RunInBackground = true;
[SerializeField] private float gameSpeed = 1f;
[SerializeField]
private bool m_NeverSleep = true;
[SerializeField] private bool runInBackground = true;
[SerializeField] private bool neverSleep = true;
/// <summary>
/// 获取或设置编辑器语言(仅编辑器内有效)。
/// </summary>
public Language EditorLanguage
{
get => m_EditorLanguage;
set => m_EditorLanguage = value;
get => editorLanguage;
set => editorLanguage = value;
}
/// <summary>
@@ -51,8 +43,8 @@ namespace TEngine
/// </summary>
public int FrameRate
{
get => m_FrameRate;
set => Application.targetFrameRate = m_FrameRate = value;
get => frameRate;
set => Application.targetFrameRate = frameRate = value;
}
/// <summary>
@@ -60,27 +52,27 @@ namespace TEngine
/// </summary>
public float GameSpeed
{
get => m_GameSpeed;
set => Time.timeScale = m_GameSpeed = value >= 0f ? value : 0f;
get => gameSpeed;
set => Time.timeScale = gameSpeed = value >= 0f ? value : 0f;
}
/// <summary>
/// 获取游戏是否暂停。
/// </summary>
public bool IsGamePaused => m_GameSpeed <= 0f;
public bool IsGamePaused => gameSpeed <= 0f;
/// <summary>
/// 获取是否正常游戏速度。
/// </summary>
public bool IsNormalGameSpeed => Math.Abs(m_GameSpeed - 1f) < 0.01f;
public bool IsNormalGameSpeed => Math.Abs(gameSpeed - 1f) < 0.01f;
/// <summary>
/// 获取或设置是否允许后台运行。
/// </summary>
public bool RunInBackground
{
get => m_RunInBackground;
set => Application.runInBackground = m_RunInBackground = value;
get => runInBackground;
set => Application.runInBackground = runInBackground = value;
}
/// <summary>
@@ -88,10 +80,10 @@ namespace TEngine
/// </summary>
public bool NeverSleep
{
get => m_NeverSleep;
get => neverSleep;
set
{
m_NeverSleep = value;
neverSleep = value;
Screen.sleepTimeout = value ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
}
}
@@ -112,11 +104,11 @@ namespace TEngine
{
Utility.Converter.ScreenDpi = DefaultDpi;
}
Application.targetFrameRate = m_FrameRate;
Time.timeScale = m_GameSpeed;
Application.runInBackground = m_RunInBackground;
Screen.sleepTimeout = m_NeverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
Application.targetFrameRate = frameRate;
Time.timeScale = gameSpeed;
Application.runInBackground = runInBackground;
Screen.sleepTimeout = neverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
Application.lowMemory += OnLowMemory;
GameTime.StartFrame();
@@ -161,7 +153,7 @@ namespace TEngine
return;
}
m_GameSpeedBeforePause = GameSpeed;
_gameSpeedBeforePause = GameSpeed;
GameSpeed = 0f;
}
@@ -175,7 +167,7 @@ namespace TEngine
return;
}
GameSpeed = m_GameSpeedBeforePause;
GameSpeed = _gameSpeedBeforePause;
}
/// <summary>
@@ -198,22 +190,22 @@ namespace TEngine
private void InitTextHelper()
{
if (string.IsNullOrEmpty(m_TextHelperTypeName))
if (string.IsNullOrEmpty(textHelperTypeName))
{
return;
}
Type textHelperType = Utility.Assembly.GetType(m_TextHelperTypeName);
Type textHelperType = Utility.Assembly.GetType(textHelperTypeName);
if (textHelperType == null)
{
Log.Error("Can not find text helper type '{0}'.", m_TextHelperTypeName);
Log.Error("Can not find text helper type '{0}'.", textHelperTypeName);
return;
}
Utility.Text.ITextHelper textHelper = (Utility.Text.ITextHelper)Activator.CreateInstance(textHelperType);
if (textHelper == null)
{
Log.Error("Can not create text helper instance '{0}'.", m_TextHelperTypeName);
Log.Error("Can not create text helper instance '{0}'.", textHelperTypeName);
return;
}
@@ -222,21 +214,24 @@ namespace TEngine
private void InitLogHelper()
{
if (string.IsNullOrEmpty(m_LogHelperTypeName))
if (string.IsNullOrEmpty(logHelperTypeName))
{
return;
}
Type logHelperType = Utility.Assembly.GetType(m_LogHelperTypeName);
Type logHelperType = Utility.Assembly.GetType(logHelperTypeName);
if (logHelperType == null)
{
throw new GameFrameworkException(Utility.Text.Format("Can not find log helper type '{0}'.", m_LogHelperTypeName));
throw new GameFrameworkException(Utility.Text.Format("Can not find log helper type '{0}'.",
logHelperTypeName));
}
GameFrameworkLog.ILogHelper logHelper = (GameFrameworkLog.ILogHelper)Activator.CreateInstance(logHelperType);
GameFrameworkLog.ILogHelper
logHelper = (GameFrameworkLog.ILogHelper)Activator.CreateInstance(logHelperType);
if (logHelper == null)
{
throw new GameFrameworkException(Utility.Text.Format("Can not create log helper instance '{0}'.", m_LogHelperTypeName));
throw new GameFrameworkException(Utility.Text.Format("Can not create log helper instance '{0}'.",
logHelperTypeName));
}
GameFrameworkLog.SetLogHelper(logHelper);
@@ -244,22 +239,22 @@ namespace TEngine
private void InitJsonHelper()
{
if (string.IsNullOrEmpty(m_JsonHelperTypeName))
if (string.IsNullOrEmpty(jsonHelperTypeName))
{
return;
}
Type jsonHelperType = Utility.Assembly.GetType(m_JsonHelperTypeName);
Type jsonHelperType = Utility.Assembly.GetType(jsonHelperTypeName);
if (jsonHelperType == null)
{
Log.Error("Can not find JSON helper type '{0}'.", m_JsonHelperTypeName);
Log.Error("Can not find JSON helper type '{0}'.", jsonHelperTypeName);
return;
}
Utility.Json.IJsonHelper jsonHelper = (Utility.Json.IJsonHelper)Activator.CreateInstance(jsonHelperType);
if (jsonHelper == null)
{
Log.Error("Can not create JSON helper instance '{0}'.", m_JsonHelperTypeName);
Log.Error("Can not create JSON helper instance '{0}'.", jsonHelperTypeName);
return;
}
@@ -269,7 +264,7 @@ namespace TEngine
private void OnLowMemory()
{
Log.Warning("Low memory reported...");
IObjectPoolModule objectPoolModule = ModuleSystem.GetModule<IObjectPoolModule>();
if (objectPoolModule != null)
{
@@ -283,4 +278,4 @@ namespace TEngine
}
}
}
}
}

View File

@@ -1,6 +1,4 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine;
namespace TEngine
{
@@ -27,13 +25,13 @@ namespace TEngine
}
[SerializeField] private AudioSetting audioSetting;
[SerializeField] private ProcedureSetting procedureSetting;
[SerializeField] private UpdateSetting updateSetting;
public static AudioSetting AudioSetting => Instance.audioSetting;
public static ProcedureSetting ProcedureSetting => Instance.procedureSetting;
public static UpdateSetting UpdateSetting => Instance.updateSetting;

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 2e3cd0841baf4f42a5ac166b4a9fce2b
timeCreated: 1705927238

View File

@@ -1,7 +0,0 @@
namespace TEngine
{
public interface IUIModule
{
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 20e1c311409e4636a6f6b07c843e6aa7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,23 +0,0 @@
using System.Collections.Generic;
namespace TEngine
{
internal class UIModule : Module, IUIModule
{
private IResourceModule _resourceModule;
public override void OnInit()
{
}
public override void Shutdown()
{
}
public void Init()
{
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: f42e54968df4423eac3a935f0f06b904
timeCreated: 1705927246

View File

@@ -13,35 +13,35 @@ MonoBehaviour:
m_Name: AudioSetting
m_EditorClassIdentifier:
audioGroupConfigs:
- m_Name: Music
m_Mute: 0
m_Volume: 0.5
m_AgentHelperCount: 1
AudioType: 2
- name: Music
mute: 0
volume: 0.5
agentHelperCount: 1
audioType: 2
audioRolloffMode: 1
minDistance: 15
maxDistance: 50
- m_Name: Sound
m_Mute: 0
m_Volume: 0.5
m_AgentHelperCount: 4
AudioType: 0
- name: Sound
mute: 0
volume: 0.5
agentHelperCount: 4
audioType: 0
audioRolloffMode: 0
minDistance: 1
maxDistance: 500
- m_Name: UISound
m_Mute: 0
m_Volume: 0.5
m_AgentHelperCount: 4
AudioType: 1
- name: UISound
mute: 0
volume: 0.5
agentHelperCount: 4
audioType: 1
audioRolloffMode: 0
minDistance: 1
maxDistance: 500
- m_Name: Voice
m_Mute: 0
m_Volume: 0.5
m_AgentHelperCount: 1
AudioType: 3
- name: Voice
mute: 0
volume: 0.5
agentHelperCount: 1
audioType: 3
audioRolloffMode: 0
minDistance: 1
maxDistance: 500

View File

@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name: Game App Config Data
m_EditorClassIdentifier: TEngine.Runtime:TEngine:GameAppConfigData
gameAppConfigInfoList: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0135d4f2f69a1d04aa9d82d50d3763db
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: