mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
统一命名规范private变量_filedInfo
This commit is contained in:
@@ -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>会实例化资源到场景,无需主动UnloadAsset,Destroy时自动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>会实例化资源到场景,无需主动UnloadAsset,Destroy时自动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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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();
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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>();
|
||||
}
|
||||
}
|
@@ -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)
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user