优化
1.重名所有App级模块为Service 2.移除Module中心 移除SingletonManager 3.引入Service Scope Context概念 避免上下文Manager到处引用 4.修复部分bug
This commit is contained in:
parent
58baa6269e
commit
cad7722e44
@ -4,7 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(GameObjectPool))]
|
[CustomEditor(typeof(GameObjectPoolManager))]
|
||||||
public sealed class GameObjectPoolEditor : UnityEditor.Editor
|
public sealed class GameObjectPoolEditor : UnityEditor.Editor
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, bool> _foldoutState = new Dictionary<string, bool>();
|
private readonly Dictionary<string, bool> _foldoutState = new Dictionary<string, bool>();
|
||||||
@ -16,7 +16,7 @@ namespace AlicizaX
|
|||||||
DrawDefaultInspector();
|
DrawDefaultInspector();
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
|
||||||
var pool = (GameObjectPool)target;
|
var pool = (GameObjectPoolManager)target;
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
{
|
{
|
||||||
EditorGUILayout.HelpBox("Enter Play Mode to inspect runtime pool state.", MessageType.Info);
|
EditorGUILayout.HelpBox("Enter Play Mode to inspect runtime pool state.", MessageType.Info);
|
||||||
@ -34,19 +34,19 @@ namespace AlicizaX
|
|||||||
|
|
||||||
public override bool RequiresConstantRepaint()
|
public override bool RequiresConstantRepaint()
|
||||||
{
|
{
|
||||||
var pool = target as GameObjectPool;
|
var pool = target as GameObjectPoolManager;
|
||||||
return pool != null && Application.isPlaying && pool.showDetailedInfo;
|
return pool != null && Application.isPlaying && pool.showDetailedInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRuntimeState(GameObjectPool pool)
|
private void DrawRuntimeState(GameObjectPoolManager poolManager)
|
||||||
{
|
{
|
||||||
if (!pool.IsReady)
|
if (!poolManager.IsReady)
|
||||||
{
|
{
|
||||||
EditorGUILayout.HelpBox("GameObjectPool is initializing.", MessageType.Info);
|
EditorGUILayout.HelpBox("GameObjectPool is initializing.", MessageType.Info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GameObjectPoolSnapshot> snapshots = pool.GetDebugSnapshots();
|
List<GameObjectPoolSnapshot> snapshots = poolManager.GetDebugSnapshots();
|
||||||
if (snapshots.Count == 0)
|
if (snapshots.Count == 0)
|
||||||
{
|
{
|
||||||
EditorGUILayout.HelpBox("No runtime pools have been created yet.", MessageType.Info);
|
EditorGUILayout.HelpBox("No runtime pools have been created yet.", MessageType.Info);
|
||||||
|
|||||||
40
Entry.prefab
40
Entry.prefab
@ -156,37 +156,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 1e28a727443c86c40aeb42ff20e0a343, type: 3}
|
m_Script: {fileID: 11500000, guid: 1e28a727443c86c40aeb42ff20e0a343, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &2946186047994278043
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 8452422965548084857}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Fsm
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &8452422965548084857
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2946186047994278043}
|
|
||||||
serializedVersion: 2
|
|
||||||
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: 425597497363353001}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &3646865557585103128
|
--- !u!1 &3646865557585103128
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -268,7 +237,6 @@ Transform:
|
|||||||
- {fileID: 424925309774805088}
|
- {fileID: 424925309774805088}
|
||||||
- {fileID: 7231588671532407876}
|
- {fileID: 7231588671532407876}
|
||||||
- {fileID: 1640076400431107710}
|
- {fileID: 1640076400431107710}
|
||||||
- {fileID: 8452422965548084857}
|
|
||||||
- {fileID: 9160912643551877041}
|
- {fileID: 9160912643551877041}
|
||||||
- {fileID: 9144434048949093429}
|
- {fileID: 9144434048949093429}
|
||||||
- {fileID: 5595937395452803435}
|
- {fileID: 5595937395452803435}
|
||||||
@ -288,6 +256,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 252fa1bb9e36411fb4582d0656b987bf, type: 3}
|
m_Script: {fileID: 11500000, guid: 252fa1bb9e36411fb4582d0656b987bf, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
_dontDestroyOnLoad: 1
|
||||||
|
_appScopeOrder: -10000
|
||||||
frameRate: 120
|
frameRate: 120
|
||||||
gameSpeed: 1
|
gameSpeed: 1
|
||||||
runInBackground: 1
|
runInBackground: 1
|
||||||
@ -304,9 +274,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: d544088dbfb44263bddb36004521fee5, type: 3}
|
m_Script: {fileID: 11500000, guid: d544088dbfb44263bddb36004521fee5, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_resourceComponent: {fileID: 7354290124713579766}
|
resourceComponent: {fileID: 7354290124713579766}
|
||||||
_debuggerComponent: {fileID: 8897508624174186059}
|
debuggerComponent: {fileID: 8897508624174186059}
|
||||||
_localizationComponent: {fileID: 1599215827984154130}
|
localizationComponent: {fileID: 1599215827984154130}
|
||||||
--- !u!1 &6519989611955579811
|
--- !u!1 &6519989611955579811
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: aeb86cc258fa4378ba3b259a5d38e4df
|
|
||||||
timeCreated: 1736424998
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
namespace AlicizaX
|
|
||||||
{
|
|
||||||
public interface IModule
|
|
||||||
{
|
|
||||||
protected internal void Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleAwake
|
|
||||||
{
|
|
||||||
protected internal void Awake();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IExecuteSystem
|
|
||||||
{
|
|
||||||
abstract int Priority { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleUpdate : IExecuteSystem
|
|
||||||
{
|
|
||||||
protected internal void Update(float elapseSeconds, float realElapseSeconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleLateUpdate : IExecuteSystem
|
|
||||||
{
|
|
||||||
protected internal void LateUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleFixedUpdate : IExecuteSystem
|
|
||||||
{
|
|
||||||
protected internal void FixedUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleDrawGizmos : IExecuteSystem
|
|
||||||
{
|
|
||||||
protected internal void DrawGizmos();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IModuleGUI : IExecuteSystem
|
|
||||||
{
|
|
||||||
protected internal void OnGUI();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0ba192d5e9084d67b16b53e843e103b3
|
|
||||||
timeCreated: 1736424999
|
|
||||||
@ -1,303 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Buffers;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AlicizaX
|
|
||||||
{
|
|
||||||
public static class ModuleSystem
|
|
||||||
{
|
|
||||||
internal const int DesignModuleCount = 32;
|
|
||||||
|
|
||||||
private static readonly Dictionary<Type, IModule> _moduleMaps = new Dictionary<Type, IModule>(DesignModuleCount);
|
|
||||||
private static readonly GameFrameworkLinkedList<IModule> _modules = new GameFrameworkLinkedList<IModule>();
|
|
||||||
|
|
||||||
// Update systems
|
|
||||||
private static readonly GameFrameworkLinkedList<IModuleUpdate> _updateModules = new GameFrameworkLinkedList<IModuleUpdate>();
|
|
||||||
private static readonly IModuleUpdate[] _updateExecuteArray = new IModuleUpdate[DesignModuleCount];
|
|
||||||
private static int _updateExecuteCount;
|
|
||||||
|
|
||||||
// LateUpdate systems
|
|
||||||
private static readonly GameFrameworkLinkedList<IModuleLateUpdate> _lateUpdateModules = new GameFrameworkLinkedList<IModuleLateUpdate>();
|
|
||||||
private static readonly IModuleLateUpdate[] _lateUpdateExecuteArray = new IModuleLateUpdate[DesignModuleCount];
|
|
||||||
private static int _lateUpdateExecuteCount;
|
|
||||||
|
|
||||||
// FixedUpdate systems
|
|
||||||
private static readonly GameFrameworkLinkedList<IModuleFixedUpdate> _fixedUpdateModules = new GameFrameworkLinkedList<IModuleFixedUpdate>();
|
|
||||||
private static readonly IModuleFixedUpdate[] _fixedUpdateExecuteArray = new IModuleFixedUpdate[DesignModuleCount];
|
|
||||||
private static int _fixedUpdateExecuteCount;
|
|
||||||
|
|
||||||
// Gizmos systems
|
|
||||||
private static readonly GameFrameworkLinkedList<IModuleDrawGizmos> _gizmosUpdateModules = new GameFrameworkLinkedList<IModuleDrawGizmos>();
|
|
||||||
private static readonly IModuleDrawGizmos[] _gizmosUpdateExecuteArray = new IModuleDrawGizmos[DesignModuleCount];
|
|
||||||
private static int _gizmosExecuteCount;
|
|
||||||
|
|
||||||
// GUI systems
|
|
||||||
private static readonly GameFrameworkLinkedList<IModuleGUI> _guiUpdateModules = new GameFrameworkLinkedList<IModuleGUI>();
|
|
||||||
private static readonly IModuleGUI[] _guiUpdateExecuteArray = new IModuleGUI[DesignModuleCount];
|
|
||||||
private static int _guiExecuteCount;
|
|
||||||
|
|
||||||
// Dirty flags
|
|
||||||
private static bool _isExecuteListDirty;
|
|
||||||
private static bool _isLateExecuteListDirty;
|
|
||||||
private static bool _isFixedExecuteListDirty;
|
|
||||||
private static bool _isGizmosExecuteListDirty;
|
|
||||||
private static bool _isGUIExecuteListDirty;
|
|
||||||
|
|
||||||
internal static void Dispose()
|
|
||||||
{
|
|
||||||
// Clear all modules and execute arrays
|
|
||||||
_updateModules.Clear();
|
|
||||||
Array.Clear(_updateExecuteArray, 0, _updateExecuteArray.Length);
|
|
||||||
_updateExecuteCount = 0;
|
|
||||||
|
|
||||||
_lateUpdateModules.Clear();
|
|
||||||
Array.Clear(_lateUpdateExecuteArray, 0, _lateUpdateExecuteArray.Length);
|
|
||||||
_lateUpdateExecuteCount = 0;
|
|
||||||
|
|
||||||
_fixedUpdateModules.Clear();
|
|
||||||
Array.Clear(_fixedUpdateExecuteArray, 0, _fixedUpdateExecuteArray.Length);
|
|
||||||
_fixedUpdateExecuteCount = 0;
|
|
||||||
|
|
||||||
_gizmosUpdateModules.Clear();
|
|
||||||
Array.Clear(_gizmosUpdateExecuteArray, 0, _gizmosUpdateExecuteArray.Length);
|
|
||||||
_gizmosExecuteCount = 0;
|
|
||||||
|
|
||||||
_guiUpdateModules.Clear();
|
|
||||||
Array.Clear(_guiUpdateExecuteArray, 0, _guiUpdateExecuteArray.Length);
|
|
||||||
_guiExecuteCount = 0;
|
|
||||||
|
|
||||||
// Dispose all modules
|
|
||||||
for (var current = _modules.Last; current != null; current = current.Previous)
|
|
||||||
{
|
|
||||||
current.Value.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
_modules.Clear();
|
|
||||||
_moduleMaps.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Public System
|
|
||||||
|
|
||||||
public static T RegisterModule<T, TImple>() where T : IModule where TImple : class, T, new()
|
|
||||||
{
|
|
||||||
Type interfaceType = typeof(T);
|
|
||||||
Type implType = typeof(TImple);
|
|
||||||
if (!interfaceType.IsInterface)
|
|
||||||
{
|
|
||||||
throw new GameFrameworkException(Utility.Text.Format("You must register module by interface, but '{0}' is not.", interfaceType.FullName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!implType.IsClass || implType.IsInterface || implType.IsAbstract)
|
|
||||||
{
|
|
||||||
throw new GameFrameworkException(Utility.Text.Format("You must register module by Class and not Interface and Abstract, but '{0}' is not.", implType.FullName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!typeof(IModule).IsAssignableFrom(interfaceType))
|
|
||||||
{
|
|
||||||
throw new GameFrameworkException(Utility.Text.Format("Module must implement IModule.", interfaceType.FullName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetModule(interfaceType) != null)
|
|
||||||
{
|
|
||||||
Log.Error("Already Register {0}", interfaceType.FullName);
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
TImple impl = new TImple();
|
|
||||||
return (T)SetModuleInstance(interfaceType, impl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T GetModule<T>() where T : class
|
|
||||||
{
|
|
||||||
Type interfaceType = typeof(T);
|
|
||||||
if (!interfaceType.IsInterface)
|
|
||||||
{
|
|
||||||
throw new GameFrameworkException(Utility.Text.Format("You must get module by interface, but '{0}' is not.", interfaceType.FullName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetModule(interfaceType) as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IModule GetModule(Type moduleType)
|
|
||||||
{
|
|
||||||
return _moduleMaps.TryGetValue(moduleType, out var ret) ? ret : default;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IModule SetModuleInstance<TImpl>(Type interfaceType, TImpl impl) where TImpl : class, IModule
|
|
||||||
{
|
|
||||||
_moduleMaps[interfaceType] = impl;
|
|
||||||
_modules.AddLast(impl);
|
|
||||||
|
|
||||||
if (impl is IModuleAwake awakeSystem)
|
|
||||||
{
|
|
||||||
awakeSystem.Awake();
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckSystemLife(impl);
|
|
||||||
return impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private static void CheckSystemLife(IModule module)
|
|
||||||
{
|
|
||||||
if (module is IModuleUpdate updateSystem)
|
|
||||||
{
|
|
||||||
BindSystemLife(updateSystem, _updateModules, ref _isExecuteListDirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module is IModuleLateUpdate lateUpdate)
|
|
||||||
{
|
|
||||||
BindSystemLife(lateUpdate, _lateUpdateModules, ref _isLateExecuteListDirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module is IModuleFixedUpdate fixedUpdate)
|
|
||||||
{
|
|
||||||
BindSystemLife(fixedUpdate, _fixedUpdateModules, ref _isFixedExecuteListDirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module is IModuleDrawGizmos drawGizmosUpdate)
|
|
||||||
{
|
|
||||||
BindSystemLife(drawGizmosUpdate, _gizmosUpdateModules, ref _isGizmosExecuteListDirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module is IModuleGUI guiUpdate)
|
|
||||||
{
|
|
||||||
BindSystemLife(guiUpdate, _guiUpdateModules, ref _isGUIExecuteListDirty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void BindSystemLife<T>(T system, GameFrameworkLinkedList<T> updateModule, ref bool executeDirty) where T : IExecuteSystem
|
|
||||||
{
|
|
||||||
var current = updateModule.First;
|
|
||||||
while (current != null && system.Priority <= current.Value.Priority)
|
|
||||||
{
|
|
||||||
current = current.Next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current != null)
|
|
||||||
{
|
|
||||||
updateModule.AddBefore(current, system);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
updateModule.AddLast(system);
|
|
||||||
}
|
|
||||||
|
|
||||||
executeDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region BuildExecuteList
|
|
||||||
|
|
||||||
private static void BuildExecuteList()
|
|
||||||
{
|
|
||||||
if (!_isExecuteListDirty) return;
|
|
||||||
_isExecuteListDirty = false;
|
|
||||||
_updateExecuteCount = 0;
|
|
||||||
foreach (var module in _updateModules)
|
|
||||||
{
|
|
||||||
if (_updateExecuteCount >= _updateExecuteArray.Length) break;
|
|
||||||
_updateExecuteArray[_updateExecuteCount++] = module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void BuildLateExecuteList()
|
|
||||||
{
|
|
||||||
if (!_isLateExecuteListDirty) return;
|
|
||||||
_isLateExecuteListDirty = false;
|
|
||||||
_lateUpdateExecuteCount = 0;
|
|
||||||
foreach (var module in _lateUpdateModules)
|
|
||||||
{
|
|
||||||
if (_lateUpdateExecuteCount >= _lateUpdateExecuteArray.Length) break;
|
|
||||||
_lateUpdateExecuteArray[_lateUpdateExecuteCount++] = module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void BuildFixedExecuteList()
|
|
||||||
{
|
|
||||||
if (!_isFixedExecuteListDirty) return;
|
|
||||||
_isFixedExecuteListDirty = false;
|
|
||||||
_fixedUpdateExecuteCount = 0;
|
|
||||||
foreach (var module in _fixedUpdateModules)
|
|
||||||
{
|
|
||||||
if (_fixedUpdateExecuteCount >= _fixedUpdateExecuteArray.Length) break;
|
|
||||||
_fixedUpdateExecuteArray[_fixedUpdateExecuteCount++] = module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void BuildGizmosExecuteList()
|
|
||||||
{
|
|
||||||
if (!_isGizmosExecuteListDirty) return;
|
|
||||||
_isGizmosExecuteListDirty = false;
|
|
||||||
_gizmosExecuteCount = 0;
|
|
||||||
foreach (var module in _gizmosUpdateModules)
|
|
||||||
{
|
|
||||||
if (_gizmosExecuteCount >= _gizmosUpdateExecuteArray.Length) break;
|
|
||||||
_gizmosUpdateExecuteArray[_gizmosExecuteCount++] = module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void BuildGUIExecuteList()
|
|
||||||
{
|
|
||||||
if (!_isGUIExecuteListDirty) return;
|
|
||||||
_isGUIExecuteListDirty = false;
|
|
||||||
_guiExecuteCount = 0;
|
|
||||||
foreach (var module in _guiUpdateModules)
|
|
||||||
{
|
|
||||||
if (_guiExecuteCount >= _guiUpdateExecuteArray.Length) break;
|
|
||||||
_guiUpdateExecuteArray[_guiExecuteCount++] = module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region RunExecuteList
|
|
||||||
|
|
||||||
internal static void UpdateExecuteList(float elapseSeconds, float realElapseSeconds)
|
|
||||||
{
|
|
||||||
BuildExecuteList();
|
|
||||||
for (int i = 0; i < _updateExecuteCount; i++)
|
|
||||||
{
|
|
||||||
_updateExecuteArray[i].Update(elapseSeconds, realElapseSeconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UpdateLateExecuteList()
|
|
||||||
{
|
|
||||||
BuildLateExecuteList();
|
|
||||||
for (int i = 0; i < _lateUpdateExecuteCount; i++)
|
|
||||||
{
|
|
||||||
_lateUpdateExecuteArray[i].LateUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UpdateFixedExecuteList()
|
|
||||||
{
|
|
||||||
BuildFixedExecuteList();
|
|
||||||
for (int i = 0; i < _fixedUpdateExecuteCount; i++)
|
|
||||||
{
|
|
||||||
_fixedUpdateExecuteArray[i].FixedUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UpdateGizmosExecuteList()
|
|
||||||
{
|
|
||||||
BuildGizmosExecuteList();
|
|
||||||
for (int i = 0; i < _gizmosExecuteCount; i++)
|
|
||||||
{
|
|
||||||
_gizmosUpdateExecuteArray[i].DrawGizmos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UpdateGUIExecuteList()
|
|
||||||
{
|
|
||||||
BuildGUIExecuteList();
|
|
||||||
for (int i = 0; i < _guiExecuteCount; i++)
|
|
||||||
{
|
|
||||||
_guiUpdateExecuteArray[i].OnGUI();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b9fa1d3abb954b57989b94b4c77e45ce
|
|
||||||
timeCreated: 1736928479
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using AlicizaX.ObjectPool;
|
using AlicizaX.ObjectPool;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -10,7 +10,7 @@ namespace AlicizaX
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
public sealed class RootModule : MonoBehaviour
|
public sealed class RootModule : AppServiceRoot
|
||||||
{
|
{
|
||||||
private static RootModule _instance = null;
|
private static RootModule _instance = null;
|
||||||
|
|
||||||
@ -134,8 +134,9 @@ namespace AlicizaX
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏框架组件初始化。
|
/// 游戏框架组件初始化。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
|
base.Awake();
|
||||||
_instance = this;
|
_instance = this;
|
||||||
DontDestroyOnLoad(this);
|
DontDestroyOnLoad(this);
|
||||||
Utility.Unity.MakeEntity(transform);
|
Utility.Unity.MakeEntity(transform);
|
||||||
@ -166,7 +167,7 @@ namespace AlicizaX
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void Shutdown()
|
private void Shutdown()
|
||||||
{
|
{
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
Utility.Unity.Shutdown();
|
Utility.Unity.Shutdown();
|
||||||
@ -174,43 +175,11 @@ namespace AlicizaX
|
|||||||
Utility.Marshal.FreeCachedHGlobal();
|
Utility.Marshal.FreeCachedHGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
ModuleSystem.UpdateExecuteList(Time.deltaTime, Time.unscaledDeltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LateUpdate()
|
|
||||||
{
|
|
||||||
ModuleSystem.UpdateLateExecuteList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
ModuleSystem.UpdateFixedExecuteList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
ModuleSystem.UpdateGizmosExecuteList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnGUI()
|
|
||||||
{
|
|
||||||
ModuleSystem.UpdateGUIExecuteList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OnDestroy()
|
|
||||||
{
|
|
||||||
await UniTask.Yield();
|
|
||||||
ModuleSystem.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void OnLowMemory()
|
private void OnLowMemory()
|
||||||
{
|
{
|
||||||
Log.Warning("Low memory reported...");
|
Log.Warning("Low memory reported...");
|
||||||
|
|
||||||
IObjectPoolModule objectPoolModule = ModuleSystem.GetModule<IObjectPoolModule>();
|
IObjectPoolService objectPoolModule = AppServices.Require<IObjectPoolService>();
|
||||||
if (objectPoolModule != null)
|
if (objectPoolModule != null)
|
||||||
{
|
{
|
||||||
objectPoolModule.ReleaseAllUnused();
|
objectPoolModule.ReleaseAllUnused();
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using Cysharp.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
@ -54,13 +55,17 @@ namespace AlicizaX
|
|||||||
if (AppServices.HasWorld) AppServices.World.DrawGizmos();
|
if (AppServices.HasWorld) AppServices.World.DrawGizmos();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDestroy()
|
protected virtual async void OnDestroy()
|
||||||
{
|
{
|
||||||
if (s_activeRoot == this)
|
if (s_activeRoot == this)
|
||||||
s_activeRoot = null;
|
s_activeRoot = null;
|
||||||
|
|
||||||
if (_ownsWorld && AppServices.HasWorld)
|
if (_ownsWorld && AppServices.HasWorld)
|
||||||
|
{
|
||||||
|
await UniTask.Yield();
|
||||||
AppServices.Shutdown();
|
AppServices.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void RegisterAppServices(ServiceScope appScope) { }
|
protected virtual void RegisterAppServices(ServiceScope appScope) { }
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
public sealed class GameObjectPool : MonoServiceBehaviour<GameObjectPool>
|
public sealed class GameObjectPoolManager : MonoServiceBehaviour<GameObjectPoolManager>
|
||||||
{
|
{
|
||||||
private static readonly Comparison<GameObjectPoolSnapshot> SnapshotComparer = (left, right) =>
|
private static readonly Comparison<GameObjectPoolSnapshot> SnapshotComparer = (left, right) =>
|
||||||
{
|
{
|
||||||
@ -17,17 +17,14 @@ namespace AlicizaX
|
|||||||
int groupCompare = string.Compare(left.group, right.group, StringComparison.Ordinal);
|
int groupCompare = string.Compare(left.group, right.group, StringComparison.Ordinal);
|
||||||
return groupCompare != 0 ? groupCompare : string.Compare(left.assetPath, right.assetPath, StringComparison.Ordinal);
|
return groupCompare != 0 ? groupCompare : string.Compare(left.assetPath, right.assetPath, StringComparison.Ordinal);
|
||||||
};
|
};
|
||||||
[Header("检查间隔")]
|
|
||||||
public float checkInterval = 10f;
|
|
||||||
|
|
||||||
[Header("配置路径")]
|
[Header("检查间隔")] public float checkInterval = 10f;
|
||||||
public string poolConfigPath = "Assets/Bundles/Configs/PoolConfig";
|
|
||||||
|
|
||||||
[Header("Inspector显示设置")]
|
[Header("配置路径")] public string poolConfigPath = "Assets/Bundles/Configs/PoolConfig";
|
||||||
public bool showDetailedInfo = true;
|
|
||||||
|
|
||||||
[SerializeField]
|
[Header("Inspector显示设置")] public bool showDetailedInfo = true;
|
||||||
internal Transform poolContainer;
|
|
||||||
|
[SerializeField] internal Transform poolContainer;
|
||||||
|
|
||||||
private const PoolResourceLoaderType DefaultDirectLoadResourceLoaderType = PoolResourceLoaderType.AssetBundle;
|
private const PoolResourceLoaderType DefaultDirectLoadResourceLoaderType = PoolResourceLoaderType.AssetBundle;
|
||||||
|
|
||||||
@ -219,6 +216,7 @@ namespace AlicizaX
|
|||||||
pool.Shutdown();
|
pool.Shutdown();
|
||||||
MemoryPool.Release(pool);
|
MemoryPool.Release(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isShuttingDown = false;
|
_isShuttingDown = false;
|
||||||
|
|
||||||
_poolsByKey.Clear();
|
_poolsByKey.Clear();
|
||||||
@ -392,9 +390,8 @@ namespace AlicizaX
|
|||||||
_resolvedConfigCache.Clear();
|
_resolvedConfigCache.Clear();
|
||||||
_groupLoaderCache.Clear();
|
_groupLoaderCache.Clear();
|
||||||
|
|
||||||
IResourceModule resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
IResourceService resourceService = AppServices.Require<IResourceService>();
|
||||||
PoolConfigScriptableObject configAsset =
|
PoolConfigScriptableObject configAsset = resourceService.LoadAsset<PoolConfigScriptableObject>(poolConfigPath);
|
||||||
resourceModule.LoadAsset<PoolConfigScriptableObject>(poolConfigPath);
|
|
||||||
|
|
||||||
if (configAsset == null || configAsset.configs == null)
|
if (configAsset == null || configAsset.configs == null)
|
||||||
{
|
{
|
||||||
@ -431,7 +428,7 @@ namespace AlicizaX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceModule.UnloadAsset(configAsset);
|
resourceService.UnloadAsset(configAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async UniTask PrewarmConfiguredPoolsAsync(CancellationToken cancellationToken)
|
private async UniTask PrewarmConfiguredPoolsAsync(CancellationToken cancellationToken)
|
||||||
@ -63,45 +63,45 @@ namespace AlicizaX
|
|||||||
|
|
||||||
public class AssetBundleResourceLoader : IResourceLoader
|
public class AssetBundleResourceLoader : IResourceLoader
|
||||||
{
|
{
|
||||||
private IResourceModule _resourceModule;
|
private IResourceService _resourceService;
|
||||||
|
|
||||||
IResourceModule ResourceModule
|
IResourceService ResourceService
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_resourceModule == null)
|
if (_resourceService == null)
|
||||||
{
|
{
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _resourceModule;
|
return _resourceService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public GameObject LoadPrefab(string location)
|
public GameObject LoadPrefab(string location)
|
||||||
{
|
{
|
||||||
return ResourceModule.LoadAsset<GameObject>(location);
|
return ResourceService.LoadAsset<GameObject>(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async UniTask<GameObject> LoadPrefabAsync(string location, CancellationToken cancellationToken = default)
|
public async UniTask<GameObject> LoadPrefabAsync(string location, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return await ResourceModule.LoadAssetAsync<GameObject>(location, cancellationToken);
|
return await ResourceService.LoadAssetAsync<GameObject>(location, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject LoadGameObject(string location, Transform parent = null)
|
public GameObject LoadGameObject(string location, Transform parent = null)
|
||||||
{
|
{
|
||||||
return ResourceModule.LoadGameObject(location, parent);
|
return ResourceService.LoadGameObject(location, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent = null, CancellationToken cancellationToken = default)
|
public async UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return await ResourceModule.LoadGameObjectAsync(location, parent, cancellationToken);
|
return await ResourceService.LoadGameObjectAsync(location, parent, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnloadAsset(GameObject gameObject)
|
public void UnloadAsset(GameObject gameObject)
|
||||||
{
|
{
|
||||||
ResourceModule.UnloadAsset(gameObject);
|
ResourceService.UnloadAsset(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,7 +128,7 @@ namespace AlicizaX
|
|||||||
private PoolConfig _config;
|
private PoolConfig _config;
|
||||||
private string _assetPath;
|
private string _assetPath;
|
||||||
private IResourceLoader _loader;
|
private IResourceLoader _loader;
|
||||||
private GameObjectPool _service;
|
private GameObjectPoolManager _service;
|
||||||
private CancellationToken _shutdownToken;
|
private CancellationToken _shutdownToken;
|
||||||
private Dictionary<GameObject, RuntimePooledInstance> _instancesByObject;
|
private Dictionary<GameObject, RuntimePooledInstance> _instancesByObject;
|
||||||
private LinkedList<RuntimePooledInstance> _inactiveInstances;
|
private LinkedList<RuntimePooledInstance> _inactiveInstances;
|
||||||
@ -151,7 +151,7 @@ namespace AlicizaX
|
|||||||
PoolConfig config,
|
PoolConfig config,
|
||||||
string assetPath,
|
string assetPath,
|
||||||
IResourceLoader loader,
|
IResourceLoader loader,
|
||||||
GameObjectPool service,
|
GameObjectPoolManager service,
|
||||||
CancellationToken shutdownToken)
|
CancellationToken shutdownToken)
|
||||||
{
|
{
|
||||||
_config = config ?? throw new ArgumentNullException(nameof(config));
|
_config = config ?? throw new ArgumentNullException(nameof(config));
|
||||||
|
|||||||
@ -3,21 +3,22 @@ using AlicizaX.Debugger.Runtime;
|
|||||||
using AlicizaX.Localization.Runtime;
|
using AlicizaX.Localization.Runtime;
|
||||||
using AlicizaX.Resource.Runtime;
|
using AlicizaX.Resource.Runtime;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
public class ModuleDynamicBind : MonoBehaviour
|
public class ModuleDynamicBind : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private ResourceComponent _resourceComponent;
|
[FormerlySerializedAs("_resourceServiceBehaviour")] [SerializeField] private ResourceComponent resourceComponent;
|
||||||
[SerializeField] private DebuggerComponent _debuggerComponent;
|
[FormerlySerializedAs("_debuggerServiceBehaviour")] [SerializeField] private DebuggerComponent debuggerComponent;
|
||||||
[SerializeField] private LocalizationComponent _localizationComponent;
|
[FormerlySerializedAs("_localizationServiceBehaviour")] [SerializeField] private LocalizationComponent localizationComponent;
|
||||||
private ModuleDynamicBindInfo _dynamicBindInfo;
|
private ModuleDynamicBindInfo _dynamicBindInfo;
|
||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
_resourceComponent = GetComponentInChildren<ResourceComponent>();
|
resourceComponent = GetComponentInChildren<ResourceComponent>();
|
||||||
_debuggerComponent = GetComponentInChildren<DebuggerComponent>();
|
debuggerComponent = GetComponentInChildren<DebuggerComponent>();
|
||||||
_localizationComponent = GetComponentInChildren<LocalizationComponent>();
|
localizationComponent = GetComponentInChildren<LocalizationComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
@ -26,20 +27,20 @@ namespace AlicizaX
|
|||||||
TextAsset text = Resources.Load<TextAsset>("ModuleDynamicBindInfo");
|
TextAsset text = Resources.Load<TextAsset>("ModuleDynamicBindInfo");
|
||||||
_dynamicBindInfo = Utility.Json.ToObject<ModuleDynamicBindInfo>(text.text);
|
_dynamicBindInfo = Utility.Json.ToObject<ModuleDynamicBindInfo>(text.text);
|
||||||
|
|
||||||
if (_resourceComponent != null)
|
if (resourceComponent != null)
|
||||||
{
|
{
|
||||||
_resourceComponent.SetPlayMode(_dynamicBindInfo.ResMode);
|
resourceComponent.SetPlayMode(_dynamicBindInfo.ResMode);
|
||||||
_resourceComponent.SetDecryptionServices(_dynamicBindInfo.DecryptionServices);
|
resourceComponent.SetDecryptionServices(_dynamicBindInfo.DecryptionServices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_debuggerComponent != null)
|
if (debuggerComponent != null)
|
||||||
{
|
{
|
||||||
_debuggerComponent.SetActiveMode(_dynamicBindInfo.DebuggerActiveWindowType);
|
debuggerComponent.SetActiveMode(_dynamicBindInfo.DebuggerActiveWindowType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_localizationComponent != null)
|
if (localizationComponent != null)
|
||||||
{
|
{
|
||||||
_localizationComponent.SetLanguage(_dynamicBindInfo.Language);
|
localizationComponent.SetLanguage(_dynamicBindInfo.Language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ namespace AlicizaX.ObjectPool
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对象池管理器。
|
/// 对象池管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IObjectPoolModule: IModule, IModuleUpdate
|
public interface IObjectPoolService : IService, IServiceTickable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取对象池数量。
|
/// 获取对象池数量。
|
||||||
@ -8,24 +8,24 @@ namespace AlicizaX
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ObjectPoolComponent : MonoBehaviour
|
public sealed class ObjectPoolComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private IObjectPoolModule _mObjectPoolModule = null;
|
private IObjectPoolService _mObjectPoolService = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取对象池数量。
|
/// 获取对象池数量。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return _mObjectPoolModule.Count; }
|
get { return _mObjectPoolService.Count; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_mObjectPoolModule = ModuleSystem.RegisterModule<IObjectPoolModule,ObjectPoolModule>();
|
_mObjectPoolService = AppServices.GetOrCreateScope<AppScope>().Register(new ObjectPoolService());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
_mObjectPoolModule = null;
|
_mObjectPoolService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -35,7 +35,7 @@ namespace AlicizaX
|
|||||||
/// <returns>所有对象池。</returns>
|
/// <returns>所有对象池。</returns>
|
||||||
public ObjectPoolBase[] GetAllObjectPools(bool sort)
|
public ObjectPoolBase[] GetAllObjectPools(bool sort)
|
||||||
{
|
{
|
||||||
return _mObjectPoolModule.GetAllObjectPools(sort);
|
return _mObjectPoolService.GetAllObjectPools(sort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
|
||||||
namespace AlicizaX.ObjectPool
|
namespace AlicizaX.ObjectPool
|
||||||
{
|
{
|
||||||
internal sealed partial class ObjectPoolModule : IObjectPoolModule
|
internal sealed partial class ObjectPoolService : IObjectPoolService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内部对象。
|
/// 内部对象。
|
||||||
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
|
||||||
namespace AlicizaX.ObjectPool
|
namespace AlicizaX.ObjectPool
|
||||||
{
|
{
|
||||||
internal sealed partial class ObjectPoolModule : IObjectPoolModule
|
internal sealed partial class ObjectPoolService : IObjectPoolService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对象池。
|
/// 对象池。
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.ObjectPool
|
namespace AlicizaX.ObjectPool
|
||||||
{
|
{
|
||||||
@ -8,7 +9,7 @@ namespace AlicizaX.ObjectPool
|
|||||||
/// 对象池管理器。
|
/// 对象池管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
internal sealed partial class ObjectPoolModule : IObjectPoolModule
|
internal sealed partial class ObjectPoolService : ServiceBase, IObjectPoolService
|
||||||
{
|
{
|
||||||
private const int DefaultCapacity = int.MaxValue;
|
private const int DefaultCapacity = int.MaxValue;
|
||||||
private const float DefaultExpireTime = float.MaxValue;
|
private const float DefaultExpireTime = float.MaxValue;
|
||||||
@ -21,7 +22,7 @@ namespace AlicizaX.ObjectPool
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化对象池管理器的新实例。
|
/// 初始化对象池管理器的新实例。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ObjectPoolModule()
|
public ObjectPoolService()
|
||||||
{
|
{
|
||||||
m_ObjectPools = new Dictionary<TypeNamePair, ObjectPoolBase>();
|
m_ObjectPools = new Dictionary<TypeNamePair, ObjectPoolBase>();
|
||||||
m_CachedAllObjectPools = new List<ObjectPoolBase>();
|
m_CachedAllObjectPools = new List<ObjectPoolBase>();
|
||||||
@ -47,18 +48,20 @@ namespace AlicizaX.ObjectPool
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||||
void IModuleUpdate.Update(float elapseSeconds, float realElapseSeconds)
|
void IServiceTickable.Tick(float deltaTime)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<TypeNamePair, ObjectPoolBase> objectPool in m_ObjectPools)
|
foreach (KeyValuePair<TypeNamePair, ObjectPoolBase> objectPool in m_ObjectPools)
|
||||||
{
|
{
|
||||||
objectPool.Value.Update(elapseSeconds, realElapseSeconds);
|
objectPool.Value.Update(Time.deltaTime,Time.unscaledDeltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭并清理对象池管理器。
|
/// 关闭并清理对象池管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize() { }
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<TypeNamePair, ObjectPoolBase> objectPool in m_ObjectPools)
|
foreach (KeyValuePair<TypeNamePair, ObjectPoolBase> objectPool in m_ObjectPools)
|
||||||
{
|
{
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using AlicizaX.Resource.Runtime;
|
using AlicizaX.Resource.Runtime;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Audio;
|
using UnityEngine.Audio;
|
||||||
@ -14,8 +14,8 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
private int _instanceId;
|
private int _instanceId;
|
||||||
private AudioSource _source;
|
private AudioSource _source;
|
||||||
private AudioData _audioData;
|
private AudioData _audioData;
|
||||||
private IAudioModule _audioModule;
|
private IAudioService _audioService;
|
||||||
private IResourceModule _resourceModule;
|
private IResourceService _resourceService;
|
||||||
private Transform _transform;
|
private Transform _transform;
|
||||||
private float _volume = 1.0f;
|
private float _volume = 1.0f;
|
||||||
private float _duration;
|
private float _duration;
|
||||||
@ -237,8 +237,8 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
/// <param name="index">音频代理辅助器编号。</param>
|
/// <param name="index">音频代理辅助器编号。</param>
|
||||||
public void Init(AudioCategory audioCategory, int index = 0)
|
public void Init(AudioCategory audioCategory, int index = 0)
|
||||||
{
|
{
|
||||||
_audioModule = ModuleSystem.GetModule<IAudioModule>();
|
_audioService = AppServices.Require<IAudioService>();
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
GameObject host = new GameObject(Utility.Text.Format("Audio Agent Helper - {0} - {1}", audioCategory.AudioMixerGroup.name, index));
|
GameObject host = new GameObject(Utility.Text.Format("Audio Agent Helper - {0} - {1}", audioCategory.AudioMixerGroup.name, index));
|
||||||
host.transform.SetParent(audioCategory.InstanceRoot);
|
host.transform.SetParent(audioCategory.InstanceRoot);
|
||||||
host.transform.localPosition = Vector3.zero;
|
host.transform.localPosition = Vector3.zero;
|
||||||
@ -269,7 +269,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
_duration = 0;
|
_duration = 0;
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
if (bInPool && _audioModule.AudioClipPool.TryGetValue(path, out var operationHandle))
|
if (bInPool && _audioService.AudioClipPool.TryGetValue(path, out var operationHandle))
|
||||||
{
|
{
|
||||||
OnAssetLoadComplete(operationHandle);
|
OnAssetLoadComplete(operationHandle);
|
||||||
return;
|
return;
|
||||||
@ -278,12 +278,12 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
if (bAsync)
|
if (bAsync)
|
||||||
{
|
{
|
||||||
_audioAgentRuntimeState = AudioAgentRuntimeState.Loading;
|
_audioAgentRuntimeState = AudioAgentRuntimeState.Loading;
|
||||||
AssetHandle handle = _resourceModule.LoadAssetAsyncHandle<AudioClip>(path);
|
AssetHandle handle = _resourceService.LoadAssetAsyncHandle<AudioClip>(path);
|
||||||
handle.Completed += OnAssetLoadComplete;
|
handle.Completed += OnAssetLoadComplete;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AssetHandle handle = _resourceModule.LoadAssetSyncHandle<AudioClip>(path);
|
AssetHandle handle = _resourceService.LoadAssetSyncHandle<AudioClip>(path);
|
||||||
OnAssetLoadComplete(handle);
|
OnAssetLoadComplete(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
{
|
{
|
||||||
if (_inPool)
|
if (_inPool)
|
||||||
{
|
{
|
||||||
_audioModule.AudioClipPool.TryAdd(handle.GetAssetInfo().Address, handle);
|
_audioService.AudioClipPool.TryAdd(handle.GetAssetInfo().Address, handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Audio;
|
using UnityEngine.Audio;
|
||||||
@ -72,7 +72,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
/// <param name="audioGroupConfig">音频轨道组配置。</param>
|
/// <param name="audioGroupConfig">音频轨道组配置。</param>
|
||||||
public AudioCategory(int maxChannel, AudioMixer audioMixer, AudioGroupConfig audioGroupConfig)
|
public AudioCategory(int maxChannel, AudioMixer audioMixer, AudioGroupConfig audioGroupConfig)
|
||||||
{
|
{
|
||||||
var audioModule = ModuleSystem.GetModule<IAudioModule>();
|
var audioModule = AppServices.Require<IAudioService>();
|
||||||
|
|
||||||
this.audioMixer = audioMixer;
|
this.audioMixer = audioMixer;
|
||||||
_maxChannel = maxChannel;
|
_maxChannel = maxChannel;
|
||||||
|
|||||||
@ -18,11 +18,11 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
|
|
||||||
[SerializeField] private AudioGroupConfig[] m_AudioGroupConfigs = null;
|
[SerializeField] private AudioGroupConfig[] m_AudioGroupConfigs = null;
|
||||||
|
|
||||||
private IAudioModule _audioModule;
|
private IAudioService _audioService;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_audioModule = ModuleSystem.RegisterModule<IAudioModule,AudioModule>();
|
_audioService = AppServices.GetOrCreateScope<AppScope>().Register(new AudioService());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -32,7 +32,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
{
|
{
|
||||||
if (m_InstanceRoot == null)
|
if (m_InstanceRoot == null)
|
||||||
{
|
{
|
||||||
m_InstanceRoot = new GameObject("[AudioModule Instances]").transform;
|
m_InstanceRoot = new GameObject("[AudioService Instances]").transform;
|
||||||
m_InstanceRoot.SetParent(gameObject.transform);
|
m_InstanceRoot.SetParent(gameObject.transform);
|
||||||
m_InstanceRoot.localScale = Vector3.one;
|
m_InstanceRoot.localScale = Vector3.one;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
m_AudioMixer = Resources.Load<AudioMixer>("AudioMixer");
|
m_AudioMixer = Resources.Load<AudioMixer>("AudioMixer");
|
||||||
}
|
}
|
||||||
|
|
||||||
_audioModule.Initialize(m_AudioGroupConfigs, m_InstanceRoot, m_AudioMixer);
|
_audioService.Initialize(m_AudioGroupConfigs, m_InstanceRoot, m_AudioMixer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -12,7 +12,7 @@ using AudioType = AlicizaX.Audio.Runtime.AudioType;
|
|||||||
|
|
||||||
namespace AlicizaX.Audio.Runtime
|
namespace AlicizaX.Audio.Runtime
|
||||||
{
|
{
|
||||||
internal class AudioModule : IAudioModule
|
internal class AudioService : ServiceBase, IAudioService
|
||||||
{
|
{
|
||||||
public const string MUSIC_VOLUME_NAME = "MusicVolume";
|
public const string MUSIC_VOLUME_NAME = "MusicVolume";
|
||||||
public const string UI_SOUND_VOLUME_NAME = "UISoundVolume";
|
public const string UI_SOUND_VOLUME_NAME = "UISoundVolume";
|
||||||
@ -321,10 +321,12 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private IResourceModule _resourceModule;
|
private IResourceService _resourceService;
|
||||||
|
|
||||||
|
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize() { }
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
StopAll(fadeout: false);
|
StopAll(fadeout: false);
|
||||||
CleanSoundPool();
|
CleanSoundPool();
|
||||||
@ -339,7 +341,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
/// <exception cref="GameFrameworkException"></exception>
|
/// <exception cref="GameFrameworkException"></exception>
|
||||||
public void Initialize(AudioGroupConfig[] audioGroupConfigs, Transform instanceRoot = null, AudioMixer audioMixer = null)
|
public void Initialize(AudioGroupConfig[] audioGroupConfigs, Transform instanceRoot = null, AudioMixer audioMixer = null)
|
||||||
{
|
{
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
if (_instanceRoot == null)
|
if (_instanceRoot == null)
|
||||||
{
|
{
|
||||||
_instanceRoot = instanceRoot;
|
_instanceRoot = instanceRoot;
|
||||||
@ -526,7 +528,7 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
{
|
{
|
||||||
if (AudioClipPool != null && !AudioClipPool.ContainsKey(path))
|
if (AudioClipPool != null && !AudioClipPool.ContainsKey(path))
|
||||||
{
|
{
|
||||||
AssetHandle assetData = _resourceModule.LoadAssetAsyncHandle<AudioClip>(path);
|
AssetHandle assetData = _resourceService.LoadAssetAsyncHandle<AudioClip>(path);
|
||||||
assetData.Completed += handle => { AudioClipPool?.Add(path, handle); };
|
assetData.Completed += handle => { AudioClipPool?.Add(path, handle); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,18 +578,19 @@ namespace AlicizaX.Audio.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||||
void IModuleUpdate.Update(float elapseSeconds, float realElapseSeconds)
|
void IServiceTickable.Tick(float deltaTime)
|
||||||
{
|
{
|
||||||
foreach (var audioCategory in _audioCategories)
|
foreach (var audioCategory in _audioCategories)
|
||||||
{
|
{
|
||||||
if (audioCategory != null)
|
if (audioCategory != null)
|
||||||
{
|
{
|
||||||
audioCategory.Update(elapseSeconds);
|
audioCategory.Update(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int Priority { get; }
|
public int Priority { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Audio;
|
using UnityEngine.Audio;
|
||||||
@ -6,7 +6,7 @@ using YooAsset;
|
|||||||
|
|
||||||
namespace AlicizaX.Audio.Runtime
|
namespace AlicizaX.Audio.Runtime
|
||||||
{
|
{
|
||||||
public interface IAudioModule:IModule,IModuleUpdate
|
public interface IAudioService:IService, IServiceTickable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总音量控制。
|
/// 总音量控制。
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using AlicizaX.ObjectPool;
|
using AlicizaX.ObjectPool;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.Debugger.Runtime
|
namespace AlicizaX.Debugger.Runtime
|
||||||
@ -7,16 +7,11 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
{
|
{
|
||||||
private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase
|
private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase
|
||||||
{
|
{
|
||||||
private IObjectPoolModule m_ObjectPoolComponent = null;
|
private IObjectPoolService m_ObjectPoolService = null;
|
||||||
|
|
||||||
public override void Initialize(params object[] args)
|
public override void Initialize(params object[] args)
|
||||||
{
|
{
|
||||||
m_ObjectPoolComponent = ModuleSystem.GetModule<IObjectPoolModule>();
|
m_ObjectPoolService = AppServices.Require<IObjectPoolService>();
|
||||||
if (m_ObjectPoolComponent == null)
|
|
||||||
{
|
|
||||||
Log.Error("Object pool component is invalid.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDrawScrollableWindow()
|
protected override void OnDrawScrollableWindow()
|
||||||
@ -24,10 +19,10 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
GUILayout.Label("<b>Object Pool Information</b>");
|
GUILayout.Label("<b>Object Pool Information</b>");
|
||||||
GUILayout.BeginVertical("box");
|
GUILayout.BeginVertical("box");
|
||||||
{
|
{
|
||||||
DrawItem("Object Pool Count", m_ObjectPoolComponent.Count.ToString());
|
DrawItem("Object Pool Count", m_ObjectPoolService.Count.ToString());
|
||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
ObjectPoolBase[] objectPools = m_ObjectPoolComponent.GetAllObjectPools(true);
|
ObjectPoolBase[] objectPools = m_ObjectPoolService.GetAllObjectPools(true);
|
||||||
for (int i = 0; i < objectPools.Length; i++)
|
for (int i = 0; i < objectPools.Length; i++)
|
||||||
{
|
{
|
||||||
DrawObjectPool(objectPools[i]);
|
DrawObjectPool(objectPools[i]);
|
||||||
|
|||||||
@ -1,67 +0,0 @@
|
|||||||
// //------------------------------------------------------------
|
|
||||||
// // Game Framework
|
|
||||||
// // Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
|
||||||
// // Homepage: https://gameframework.cn/
|
|
||||||
// // Feedback: mailto:ellan@gameframework.cn
|
|
||||||
// //------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// using GameFrameX.Runtime;
|
|
||||||
// using UnityEngine;
|
|
||||||
//
|
|
||||||
// namespace GameFrameX.Debugger.Runtime
|
|
||||||
// {
|
|
||||||
// public sealed partial class DebuggerComponent : GameFrameworkComponent
|
|
||||||
// {
|
|
||||||
// private sealed class OperationsWindow : ScrollableDebuggerWindowBase
|
|
||||||
// {
|
|
||||||
// protected override void OnDrawScrollableWindow()
|
|
||||||
// {
|
|
||||||
// GUILayout.Label("<b>Operations</b>");
|
|
||||||
// GUILayout.BeginVertical("box");
|
|
||||||
// {
|
|
||||||
// ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent<ObjectPoolComponent>();
|
|
||||||
// if (objectPoolComponent != null)
|
|
||||||
// {
|
|
||||||
// if (GUILayout.Button("Object Pool Release", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// objectPoolComponent.Release();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (GUILayout.Button("Object Pool Release All Unused", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// objectPoolComponent.ReleaseAllUnused();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ResourceComponent resourceCompoent = GameEntry.GetComponent<ResourceComponent>();
|
|
||||||
// if (resourceCompoent != null)
|
|
||||||
// {
|
|
||||||
// if (GUILayout.Button("Unload Unused Assets", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// resourceCompoent.ForceUnloadUnusedAssets(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (GUILayout.Button("Unload Unused Assets and Garbage Collect", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// resourceCompoent.ForceUnloadUnusedAssets(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (GUILayout.Button("Shutdown Game Framework (None)", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// GameEntry.Shutdown(ShutdownType.None);
|
|
||||||
// }
|
|
||||||
// if (GUILayout.Button("Shutdown Game Framework (Restart)", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// GameEntry.Shutdown(ShutdownType.Restart);
|
|
||||||
// }
|
|
||||||
// if (GUILayout.Button("Shutdown Game Framework (Quit)", GUILayout.Height(30f)))
|
|
||||||
// {
|
|
||||||
// GameEntry.Shutdown(ShutdownType.Quit);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// GUILayout.EndVertical();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a695dd87b92d7374fbe3790f5a25e9d5
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -7,7 +7,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
{
|
{
|
||||||
private sealed class SettingsWindow : ScrollableDebuggerWindowBase
|
private sealed class SettingsWindow : ScrollableDebuggerWindowBase
|
||||||
{
|
{
|
||||||
private DebuggerComponent m_DebuggerComponent = null;
|
private DebuggerComponent _mDebuggerComponent = null;
|
||||||
private float m_LastIconX = 0f;
|
private float m_LastIconX = 0f;
|
||||||
private float m_LastIconY = 0f;
|
private float m_LastIconY = 0f;
|
||||||
private float m_LastWindowX = 0f;
|
private float m_LastWindowX = 0f;
|
||||||
@ -18,8 +18,8 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
|
|
||||||
public override void Initialize(params object[] args)
|
public override void Initialize(params object[] args)
|
||||||
{
|
{
|
||||||
m_DebuggerComponent = DebuggerComponent.Instance;
|
_mDebuggerComponent = DebuggerComponent.Instance;
|
||||||
if (m_DebuggerComponent == null)
|
if (_mDebuggerComponent == null)
|
||||||
{
|
{
|
||||||
Log.Error("Debugger component is invalid.");
|
Log.Error("Debugger component is invalid.");
|
||||||
return;
|
return;
|
||||||
@ -32,53 +32,53 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
m_LastWindowY = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
|
m_LastWindowY = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
|
||||||
m_LastWindowWidth = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
|
m_LastWindowWidth = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
|
||||||
m_LastWindowHeight = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
|
m_LastWindowHeight = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
|
||||||
m_DebuggerComponent.WindowScale = m_LastWindowScale = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
|
_mDebuggerComponent.WindowScale = m_LastWindowScale = Utility.PlayerPrefsX.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
|
||||||
m_DebuggerComponent.IconRect = new Rect(m_LastIconX, m_LastIconY, DefaultIconRect.width, DefaultIconRect.height);
|
_mDebuggerComponent.IconRect = new Rect(m_LastIconX, m_LastIconY, DefaultIconRect.width, DefaultIconRect.height);
|
||||||
m_DebuggerComponent.WindowRect = new Rect(m_LastWindowX, m_LastWindowY, m_LastWindowWidth, m_LastWindowHeight);
|
_mDebuggerComponent.WindowRect = new Rect(m_LastWindowX, m_LastWindowY, m_LastWindowWidth, m_LastWindowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||||
{
|
{
|
||||||
if (m_LastIconX != m_DebuggerComponent.IconRect.x)
|
if (m_LastIconX != _mDebuggerComponent.IconRect.x)
|
||||||
{
|
{
|
||||||
m_LastIconX = m_DebuggerComponent.IconRect.x;
|
m_LastIconX = _mDebuggerComponent.IconRect.x;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.X", m_DebuggerComponent.IconRect.x);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.X", _mDebuggerComponent.IconRect.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastIconY != m_DebuggerComponent.IconRect.y)
|
if (m_LastIconY != _mDebuggerComponent.IconRect.y)
|
||||||
{
|
{
|
||||||
m_LastIconY = m_DebuggerComponent.IconRect.y;
|
m_LastIconY = _mDebuggerComponent.IconRect.y;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.Y", m_DebuggerComponent.IconRect.y);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Icon.Y", _mDebuggerComponent.IconRect.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastWindowX != m_DebuggerComponent.WindowRect.x)
|
if (m_LastWindowX != _mDebuggerComponent.WindowRect.x)
|
||||||
{
|
{
|
||||||
m_LastWindowX = m_DebuggerComponent.WindowRect.x;
|
m_LastWindowX = _mDebuggerComponent.WindowRect.x;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Window.X", m_DebuggerComponent.WindowRect.x);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.X", _mDebuggerComponent.WindowRect.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastWindowY != m_DebuggerComponent.WindowRect.y)
|
if (m_LastWindowY != _mDebuggerComponent.WindowRect.y)
|
||||||
{
|
{
|
||||||
m_LastWindowY = m_DebuggerComponent.WindowRect.y;
|
m_LastWindowY = _mDebuggerComponent.WindowRect.y;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Y", m_DebuggerComponent.WindowRect.y);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Y", _mDebuggerComponent.WindowRect.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastWindowWidth != m_DebuggerComponent.WindowRect.width)
|
if (m_LastWindowWidth != _mDebuggerComponent.WindowRect.width)
|
||||||
{
|
{
|
||||||
m_LastWindowWidth = m_DebuggerComponent.WindowRect.width;
|
m_LastWindowWidth = _mDebuggerComponent.WindowRect.width;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Width", m_DebuggerComponent.WindowRect.width);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Width", _mDebuggerComponent.WindowRect.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastWindowHeight != m_DebuggerComponent.WindowRect.height)
|
if (m_LastWindowHeight != _mDebuggerComponent.WindowRect.height)
|
||||||
{
|
{
|
||||||
m_LastWindowHeight = m_DebuggerComponent.WindowRect.height;
|
m_LastWindowHeight = _mDebuggerComponent.WindowRect.height;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Height", m_DebuggerComponent.WindowRect.height);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Height", _mDebuggerComponent.WindowRect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LastWindowScale != m_DebuggerComponent.WindowScale)
|
if (m_LastWindowScale != _mDebuggerComponent.WindowScale)
|
||||||
{
|
{
|
||||||
m_LastWindowScale = m_DebuggerComponent.WindowScale;
|
m_LastWindowScale = _mDebuggerComponent.WindowScale;
|
||||||
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Scale", m_DebuggerComponent.WindowScale);
|
Utility.PlayerPrefsX.SetFloat("Debugger.Window.Scale", _mDebuggerComponent.WindowScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
{
|
{
|
||||||
float width = m_DebuggerComponent.WindowRect.width;
|
float width = _mDebuggerComponent.WindowRect.width;
|
||||||
GUILayout.Label("Width:", GUILayout.Width(60f));
|
GUILayout.Label("Width:", GUILayout.Width(60f));
|
||||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||||
{
|
{
|
||||||
@ -110,16 +110,16 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
width = Mathf.Clamp(width, 100f, Screen.width - 20f);
|
width = Mathf.Clamp(width, 100f, Screen.width - 20f);
|
||||||
if (width != m_DebuggerComponent.WindowRect.width)
|
if (width != _mDebuggerComponent.WindowRect.width)
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowRect = new Rect(m_DebuggerComponent.WindowRect.x, m_DebuggerComponent.WindowRect.y, width, m_DebuggerComponent.WindowRect.height);
|
_mDebuggerComponent.WindowRect = new Rect(_mDebuggerComponent.WindowRect.x, _mDebuggerComponent.WindowRect.y, width, _mDebuggerComponent.WindowRect.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
{
|
{
|
||||||
float height = m_DebuggerComponent.WindowRect.height;
|
float height = _mDebuggerComponent.WindowRect.height;
|
||||||
GUILayout.Label("Height:", GUILayout.Width(60f));
|
GUILayout.Label("Height:", GUILayout.Width(60f));
|
||||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||||
{
|
{
|
||||||
@ -133,16 +133,16 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
height = Mathf.Clamp(height, 100f, Screen.height - 20f);
|
height = Mathf.Clamp(height, 100f, Screen.height - 20f);
|
||||||
if (height != m_DebuggerComponent.WindowRect.height)
|
if (height != _mDebuggerComponent.WindowRect.height)
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowRect = new Rect(m_DebuggerComponent.WindowRect.x, m_DebuggerComponent.WindowRect.y, m_DebuggerComponent.WindowRect.width, height);
|
_mDebuggerComponent.WindowRect = new Rect(_mDebuggerComponent.WindowRect.x, _mDebuggerComponent.WindowRect.y, _mDebuggerComponent.WindowRect.width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
{
|
{
|
||||||
float scale = m_DebuggerComponent.WindowScale;
|
float scale = _mDebuggerComponent.WindowScale;
|
||||||
GUILayout.Label("Scale:", GUILayout.Width(60f));
|
GUILayout.Label("Scale:", GUILayout.Width(60f));
|
||||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||||
{
|
{
|
||||||
@ -156,9 +156,9 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
scale = Mathf.Clamp(scale, 0.5f, 4f);
|
scale = Mathf.Clamp(scale, 0.5f, 4f);
|
||||||
if (scale != m_DebuggerComponent.WindowScale)
|
if (scale != _mDebuggerComponent.WindowScale)
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = scale;
|
_mDebuggerComponent.WindowScale = scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
@ -167,49 +167,49 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
{
|
{
|
||||||
if (GUILayout.Button("0.5x", GUILayout.Height(60f)))
|
if (GUILayout.Button("0.5x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 0.5f;
|
_mDebuggerComponent.WindowScale = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("1.0x", GUILayout.Height(60f)))
|
if (GUILayout.Button("1.0x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 1f;
|
_mDebuggerComponent.WindowScale = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("1.5x", GUILayout.Height(60f)))
|
if (GUILayout.Button("1.5x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 1.5f;
|
_mDebuggerComponent.WindowScale = 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("2.0x", GUILayout.Height(60f)))
|
if (GUILayout.Button("2.0x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 2f;
|
_mDebuggerComponent.WindowScale = 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("2.5x", GUILayout.Height(60f)))
|
if (GUILayout.Button("2.5x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 2.5f;
|
_mDebuggerComponent.WindowScale = 2.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("3.0x", GUILayout.Height(60f)))
|
if (GUILayout.Button("3.0x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 3f;
|
_mDebuggerComponent.WindowScale = 3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("3.5x", GUILayout.Height(60f)))
|
if (GUILayout.Button("3.5x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 3.5f;
|
_mDebuggerComponent.WindowScale = 3.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("4.0x", GUILayout.Height(60f)))
|
if (GUILayout.Button("4.0x", GUILayout.Height(60f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.WindowScale = 4f;
|
_mDebuggerComponent.WindowScale = 4f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
if (GUILayout.Button("Reset Layout", GUILayout.Height(30f)))
|
if (GUILayout.Button("Reset Layout", GUILayout.Height(30f)))
|
||||||
{
|
{
|
||||||
m_DebuggerComponent.ResetLayout();
|
_mDebuggerComponent.ResetLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
@ -43,7 +43,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
internal static readonly float DefaultWindowScale = 1f;
|
internal static readonly float DefaultWindowScale = 1f;
|
||||||
|
|
||||||
// private static readonly TextEditor s_TextEditor = new TextEditor();
|
// private static readonly TextEditor s_TextEditor = new TextEditor();
|
||||||
private IDebuggerModule _mDebuggerModule = null;
|
private IDebuggerService _mDebuggerService = null;
|
||||||
private Rect m_DragRect = new Rect(0f, 0f, float.MaxValue, 25f);
|
private Rect m_DragRect = new Rect(0f, 0f, float.MaxValue, 25f);
|
||||||
private Rect m_IconRect = DefaultIconRect;
|
private Rect m_IconRect = DefaultIconRect;
|
||||||
private Rect m_WindowRect = DefaultWindowRect;
|
private Rect m_WindowRect = DefaultWindowRect;
|
||||||
@ -99,10 +99,10 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ActiveWindow
|
public bool ActiveWindow
|
||||||
{
|
{
|
||||||
get { return _mDebuggerModule.ActiveWindow; }
|
get { return _mDebuggerService.ActiveWindow; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_mDebuggerModule.ActiveWindow = value;
|
_mDebuggerService.ActiveWindow = value;
|
||||||
enabled = value;
|
enabled = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,8 +149,8 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_instance = this;
|
_instance = this;
|
||||||
_mDebuggerModule = ModuleSystem.RegisterModule<IDebuggerModule, DebuggerModule>();
|
_mDebuggerService = AppServices.GetOrCreateScope<AppScope>().Register(new DebuggerService());
|
||||||
if (_mDebuggerModule == null)
|
if (_mDebuggerService == null)
|
||||||
{
|
{
|
||||||
Log.Error("Debugger manager is invalid.");
|
Log.Error("Debugger manager is invalid.");
|
||||||
return;
|
return;
|
||||||
@ -231,7 +231,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
if (_mDebuggerModule == null || !_mDebuggerModule.ActiveWindow)
|
if (_mDebuggerService == null || !_mDebuggerService.ActiveWindow)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// <param name="args">初始化调试器窗口参数。</param>
|
/// <param name="args">初始化调试器窗口参数。</param>
|
||||||
public void RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow, params object[] args)
|
public void RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow, params object[] args)
|
||||||
{
|
{
|
||||||
_mDebuggerModule.RegisterDebuggerWindow(path, debuggerWindow, args);
|
_mDebuggerService.RegisterDebuggerWindow(path, debuggerWindow, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -273,7 +273,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// <returns>是否解除注册调试器窗口成功。</returns>
|
/// <returns>是否解除注册调试器窗口成功。</returns>
|
||||||
public bool UnregisterDebuggerWindow(string path)
|
public bool UnregisterDebuggerWindow(string path)
|
||||||
{
|
{
|
||||||
return _mDebuggerModule.UnregisterDebuggerWindow(path);
|
return _mDebuggerService.UnregisterDebuggerWindow(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -283,7 +283,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// <returns>要获取的调试器窗口。</returns>
|
/// <returns>要获取的调试器窗口。</returns>
|
||||||
public IDebuggerWindow GetDebuggerWindow(string path)
|
public IDebuggerWindow GetDebuggerWindow(string path)
|
||||||
{
|
{
|
||||||
return _mDebuggerModule.GetDebuggerWindow(path);
|
return _mDebuggerService.GetDebuggerWindow(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -293,7 +293,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// <returns>是否成功选中调试器窗口。</returns>
|
/// <returns>是否成功选中调试器窗口。</returns>
|
||||||
public bool SelectDebuggerWindow(string path)
|
public bool SelectDebuggerWindow(string path)
|
||||||
{
|
{
|
||||||
return _mDebuggerModule.SelectDebuggerWindow(path);
|
return _mDebuggerService.SelectDebuggerWindow(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -328,7 +328,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
private void DrawWindow(int windowId)
|
private void DrawWindow(int windowId)
|
||||||
{
|
{
|
||||||
GUI.DragWindow(m_DragRect);
|
GUI.DragWindow(m_DragRect);
|
||||||
DrawDebuggerWindowGroup(_mDebuggerModule.DebuggerWindowRoot);
|
DrawDebuggerWindowGroup(_mDebuggerService.DebuggerWindowRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDebuggerWindowGroup(IDebuggerWindowGroup debuggerWindowGroup)
|
private void DrawDebuggerWindowGroup(IDebuggerWindowGroup debuggerWindowGroup)
|
||||||
@ -345,7 +345,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
names.Add(Utility.Text.Format("<b>{0}</b>", debuggerWindowNames[i]));
|
names.Add(Utility.Text.Format("<b>{0}</b>", debuggerWindowNames[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debuggerWindowGroup == _mDebuggerModule.DebuggerWindowRoot)
|
if (debuggerWindowGroup == _mDebuggerService.DebuggerWindowRoot)
|
||||||
{
|
{
|
||||||
names.Add("<b>Close</b>");
|
names.Add("<b>Close</b>");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
|
||||||
namespace AlicizaX.Debugger.Runtime
|
namespace AlicizaX.Debugger.Runtime
|
||||||
{
|
{
|
||||||
internal sealed partial class DebuggerModule : IDebuggerModule
|
internal sealed partial class DebuggerService : IDebuggerService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 调试器窗口组。
|
/// 调试器窗口组。
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.Debugger.Runtime
|
namespace AlicizaX.Debugger.Runtime
|
||||||
{
|
{
|
||||||
@ -6,7 +7,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// 调试器管理器。
|
/// 调试器管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
internal sealed partial class DebuggerModule : IDebuggerModule
|
internal sealed partial class DebuggerService : ServiceBase, IDebuggerService
|
||||||
{
|
{
|
||||||
private readonly DebuggerWindowGroup m_DebuggerWindowRoot;
|
private readonly DebuggerWindowGroup m_DebuggerWindowRoot;
|
||||||
private bool m_ActiveWindow;
|
private bool m_ActiveWindow;
|
||||||
@ -15,7 +16,7 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// 初始化调试器管理器的新实例。
|
/// 初始化调试器管理器的新实例。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
public DebuggerModule()
|
public DebuggerService()
|
||||||
{
|
{
|
||||||
m_DebuggerWindowRoot = new DebuggerWindowGroup();
|
m_DebuggerWindowRoot = new DebuggerWindowGroup();
|
||||||
m_ActiveWindow = false;
|
m_ActiveWindow = false;
|
||||||
@ -48,20 +49,22 @@ namespace AlicizaX.Debugger.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||||
void IModuleUpdate.Update(float elapseSeconds, float realElapseSeconds)
|
void IServiceTickable.Tick(float deltaTime)
|
||||||
{
|
{
|
||||||
if (!m_ActiveWindow)
|
if (!m_ActiveWindow)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DebuggerWindowRoot.OnUpdate(elapseSeconds, realElapseSeconds);
|
m_DebuggerWindowRoot.OnUpdate(Time.deltaTime,Time.realtimeSinceStartup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭并清理调试器管理器。
|
/// 关闭并清理调试器管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize() { }
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
m_ActiveWindow = false;
|
m_ActiveWindow = false;
|
||||||
m_DebuggerWindowRoot.Shutdown();
|
m_DebuggerWindowRoot.Shutdown();
|
||||||
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
@ -6,7 +6,7 @@ using AlicizaX;
|
|||||||
namespace AlicizaX.Debugger.Runtime
|
namespace AlicizaX.Debugger.Runtime
|
||||||
{
|
{
|
||||||
/// <summary>调试器管理器接口。</summary>
|
/// <summary>调试器管理器接口。</summary>
|
||||||
public interface IDebuggerModule:IModule,IModuleUpdate
|
public interface IDebuggerService:IService, IServiceTickable
|
||||||
{
|
{
|
||||||
/// <summary>获取或设置调试器窗口是否激活。</summary>
|
/// <summary>获取或设置调试器窗口是否激活。</summary>
|
||||||
bool ActiveWindow { get; set; }
|
bool ActiveWindow { get; set; }
|
||||||
164
Runtime/GameApp.cs
Normal file
164
Runtime/GameApp.cs
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
using AlicizaX;
|
||||||
|
using AlicizaX.Audio.Runtime;
|
||||||
|
using AlicizaX.Localization.Runtime;
|
||||||
|
using AlicizaX.ObjectPool;
|
||||||
|
using AlicizaX.Resource.Runtime;
|
||||||
|
using AlicizaX.Scene.Runtime;
|
||||||
|
using AlicizaX.UI.Runtime;
|
||||||
|
|
||||||
|
public static partial class GameApp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取游戏基础组件。
|
||||||
|
/// </summary>
|
||||||
|
public static RootModule Base => RootModule.Instance;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取声音组件。
|
||||||
|
/// </summary>
|
||||||
|
public static IAudioService Audio
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_audio == null)
|
||||||
|
{
|
||||||
|
_audio = AppServices.App.Require<IAudioService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _audio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IAudioService _audio;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取本地化组件。
|
||||||
|
/// </summary>
|
||||||
|
public static ILocalizationService Localization
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_localization == null)
|
||||||
|
{
|
||||||
|
_localization = AppServices.App.Require<ILocalizationService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _localization;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ILocalizationService _localization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取对象池组件。
|
||||||
|
/// </summary>
|
||||||
|
public static IObjectPoolService ObjectPool
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_objectPool == null)
|
||||||
|
{
|
||||||
|
_objectPool = AppServices.App.Require<IObjectPoolService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _objectPool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IObjectPoolService _objectPool;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取有限状态机组件。
|
||||||
|
/// </summary>
|
||||||
|
public static IProcedureService Procedure
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_procedure == null)
|
||||||
|
{
|
||||||
|
_procedure = AppServices.App.Require<IProcedureService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _procedure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IProcedureService _procedure;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取Asset组件。
|
||||||
|
/// </summary>
|
||||||
|
public static IResourceService Resource
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_resource == null)
|
||||||
|
{
|
||||||
|
_resource = AppServices.App.Require<IResourceService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IResourceService _resource;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取场景组件。
|
||||||
|
/// </summary>
|
||||||
|
public static ISceneService Scene
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_scene == null)
|
||||||
|
{
|
||||||
|
_scene = AppServices.App.Require<ISceneService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _scene;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ISceneService _scene;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取定时器组件。
|
||||||
|
/// </summary>
|
||||||
|
public static ITimerService Timer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_timer == null)
|
||||||
|
{
|
||||||
|
_timer = AppServices.App.Require<ITimerService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _timer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITimerService _timer;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取UI组件。
|
||||||
|
/// </summary>
|
||||||
|
public static IUIService UI
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_ui == null)
|
||||||
|
{
|
||||||
|
_ui = AppServices.App.Require<IUIService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _ui;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IUIService _ui;
|
||||||
|
}
|
||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f06920c335296ea4694dab52e8bd493a
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
using AlicizaX.Audio.Runtime;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取声音组件。
|
|
||||||
/// </summary>
|
|
||||||
public static IAudioModule Audio
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_audio == null)
|
|
||||||
{
|
|
||||||
_audio = ModuleSystem.GetModule<IAudioModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _audio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IAudioModule _audio;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3e9812a7462843d48a0660209e7bf8aa
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX.Localization.Runtime;
|
|
||||||
using AlicizaX;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取本地化组件。
|
|
||||||
/// </summary>
|
|
||||||
public static ILocalizationModule Localization
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_localization == null)
|
|
||||||
{
|
|
||||||
_localization = ModuleSystem.GetModule<ILocalizationModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _localization;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static ILocalizationModule _localization;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a8c610d4005146509b2dd9a685bb15af
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX.ObjectPool;
|
|
||||||
using AlicizaX;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取对象池组件。
|
|
||||||
/// </summary>
|
|
||||||
public static IObjectPoolModule ObjectPool
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_objectPool == null)
|
|
||||||
{
|
|
||||||
_objectPool = ModuleSystem.GetModule<IObjectPoolModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _objectPool;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IObjectPoolModule _objectPool;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 10a6970b6ffc472d801816ffbdf8f1e1
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取有限状态机组件。
|
|
||||||
/// </summary>
|
|
||||||
public static IProcedureModule Procedure
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_procedure == null)
|
|
||||||
{
|
|
||||||
_procedure = ModuleSystem.GetModule<IProcedureModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _procedure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IProcedureModule _procedure;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 577055df4d464c3999cdd432e009000e
|
|
||||||
timeCreated: 1763452169
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX.Resource.Runtime;
|
|
||||||
using AlicizaX;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取Asset组件。
|
|
||||||
/// </summary>
|
|
||||||
public static IResourceModule Resource
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_resource == null)
|
|
||||||
{
|
|
||||||
_resource = ModuleSystem.GetModule<IResourceModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _resource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IResourceModule _resource;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ba1f965b36d44ae2ac5820bc7fbb64ac
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
using AlicizaX.Scene.Runtime;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取场景组件。
|
|
||||||
/// </summary>
|
|
||||||
public static ISceneModule Scene
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_scene == null)
|
|
||||||
{
|
|
||||||
_scene = ModuleSystem.GetModule<ISceneModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _scene;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static ISceneModule _scene;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 214b27a946ff481fb669e0cf645398ee
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
using AlicizaX.Timer.Runtime;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取定时器组件。
|
|
||||||
/// </summary>
|
|
||||||
public static ITimerModule Timer
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_timer == null)
|
|
||||||
{
|
|
||||||
_timer = ModuleSystem.GetModule<ITimerModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _timer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static ITimerModule _timer;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 669e997f79b44a11bf93c9da9af48397
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
using AlicizaX.UI.Runtime;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取UI组件。
|
|
||||||
/// </summary>
|
|
||||||
public static IUIModule UI
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_ui == null)
|
|
||||||
{
|
|
||||||
_ui = ModuleSystem.GetModule<IUIModule>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _ui;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static IUIModule _ui;
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 198f337af87540e2be6fe76fa1abec0f
|
|
||||||
timeCreated: 1737440423
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
using AlicizaX;
|
|
||||||
|
|
||||||
public static partial class GameApp
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取游戏基础组件。
|
|
||||||
/// </summary>
|
|
||||||
public static RootModule Base
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_base == null)
|
|
||||||
{
|
|
||||||
_base = RootModule.Instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _base;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static RootModule _base;
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
#if UNITY_EDITOR
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
internal static class GameAppStaticMemberReset
|
|
||||||
{
|
|
||||||
[UnityEditor.Callbacks.DidReloadScripts]
|
|
||||||
private static void ResetAllEventContainers()
|
|
||||||
{
|
|
||||||
GameApp._base = null;
|
|
||||||
GameApp._audio = null;
|
|
||||||
GameApp._localization = null;
|
|
||||||
|
|
||||||
#if ALICIZAX_NETWORK
|
|
||||||
GameApp._network = null;
|
|
||||||
#endif
|
|
||||||
GameApp._objectPool = null;
|
|
||||||
GameApp._resource = null;
|
|
||||||
GameApp._scene = null;
|
|
||||||
GameApp._timer = null;
|
|
||||||
GameApp._ui = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a0120d62fb8349d58e950bdaa50145e4
|
|
||||||
timeCreated: 1743593118
|
|
||||||
@ -9,7 +9,7 @@ namespace AlicizaX.Localization.Runtime
|
|||||||
[AddComponentMenu("Game Framework/Localization")]
|
[AddComponentMenu("Game Framework/Localization")]
|
||||||
public sealed class LocalizationComponent : MonoBehaviour
|
public sealed class LocalizationComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private ILocalizationModule _mLocalizationModule = null;
|
private ILocalizationService _mLocalizationService = null;
|
||||||
|
|
||||||
public static string PrefsKey = Application.dataPath.GetHashCode() + "Language";
|
public static string PrefsKey = Application.dataPath.GetHashCode() + "Language";
|
||||||
|
|
||||||
@ -22,15 +22,15 @@ namespace AlicizaX.Localization.Runtime
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_mLocalizationModule = ModuleSystem.RegisterModule<ILocalizationModule, LocalizationModule>();
|
_mLocalizationService = AppServices.GetOrCreateScope<AppScope>().Register(new LocalizationService());
|
||||||
if (_mLocalizationModule == null)
|
if (_mLocalizationService == null)
|
||||||
{
|
{
|
||||||
Log.Info("Localization manager is invalid.");
|
Log.Info("Localization manager is invalid.");
|
||||||
}
|
}
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
_language = UnityEditor.EditorPrefs.GetString(LocalizationComponent.PrefsKey, "None");
|
_language = UnityEditor.EditorPrefs.GetString(LocalizationComponent.PrefsKey, "None");
|
||||||
#endif
|
#endif
|
||||||
_mLocalizationModule.Initialize(_language);
|
_mLocalizationService.Initialize(_language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace AlicizaX.Localization.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 本地化管理器接口。
|
/// 本地化管理器接口。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ILocalizationModule : IModule
|
public interface ILocalizationService : IService
|
||||||
{
|
{
|
||||||
public string Language { get; }
|
public string Language { get; }
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ namespace AlicizaX.Localization.Runtime
|
|||||||
/// 本地化管理器。
|
/// 本地化管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
internal sealed partial class LocalizationModule : ILocalizationModule
|
internal sealed partial class LocalizationService : ServiceBase, ILocalizationService
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, string> Dic = new();
|
private readonly Dictionary<string, string> Dic = new();
|
||||||
private string _language;
|
private string _language;
|
||||||
@ -749,7 +749,9 @@ namespace AlicizaX.Localization.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize() { }
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
Dic.Clear();
|
Dic.Clear();
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
public interface IProcedureModule:IModule,IModuleUpdate
|
public interface IProcedureService:IService, IServiceTickable
|
||||||
{
|
{
|
||||||
void InitializeProcedure(List<IProcedure> availableProcedures, Type defaultProcedureType);
|
void InitializeProcedure(List<IProcedure> availableProcedures, Type defaultProcedureType);
|
||||||
void ClearAllProcedures();
|
void ClearAllProcedures();
|
||||||
@ -2,7 +2,7 @@ namespace AlicizaX
|
|||||||
{
|
{
|
||||||
public interface IProcedure
|
public interface IProcedure
|
||||||
{
|
{
|
||||||
IProcedureModule ProcedureModule { get; set; }
|
IProcedureService ProcedureService { get; set; }
|
||||||
void Init();
|
void Init();
|
||||||
void Enter();
|
void Enter();
|
||||||
void Leave();
|
void Leave();
|
||||||
@ -15,7 +15,7 @@ namespace AlicizaX
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ProcedureBase : IProcedure
|
public abstract class ProcedureBase : IProcedure
|
||||||
{
|
{
|
||||||
public IProcedureModule ProcedureModule { get; set; }
|
public IProcedureService ProcedureService { get; set; }
|
||||||
|
|
||||||
void IProcedure.Init()
|
void IProcedure.Init()
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ namespace AlicizaX
|
|||||||
|
|
||||||
protected internal void SwitchProcedure<T>() where T : ProcedureBase
|
protected internal void SwitchProcedure<T>() where T : ProcedureBase
|
||||||
{
|
{
|
||||||
ProcedureModule.SwitchProcedure<T>();
|
AppServices.Require<IProcedureService>().SwitchProcedure<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,9 @@ namespace AlicizaX
|
|||||||
[AddComponentMenu("Game Framework/Procedure")]
|
[AddComponentMenu("Game Framework/Procedure")]
|
||||||
public sealed class ProcedureComponent : MonoBehaviour
|
public sealed class ProcedureComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private IProcedureModule _mProcedureModule = null;
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_mProcedureModule = ModuleSystem.RegisterModule<IProcedureModule, ProcedureModule>();
|
AppServices.GetOrCreateScope<AppScope>().Register(new ProcedureService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
internal class ProcedureModule : IProcedureModule
|
internal class ProcedureService : ServiceBase, IProcedureService
|
||||||
{
|
{
|
||||||
private readonly Dictionary<Type, IProcedure> _procedures = new Dictionary<Type, IProcedure>();
|
private readonly Dictionary<Type, IProcedure> _procedures = new Dictionary<Type, IProcedure>();
|
||||||
private IProcedure _currentProcedure;
|
private IProcedure _currentProcedure;
|
||||||
@ -18,7 +18,7 @@ namespace AlicizaX
|
|||||||
{
|
{
|
||||||
var type = procedure.GetType();
|
var type = procedure.GetType();
|
||||||
_procedures[type] = procedure;
|
_procedures[type] = procedure;
|
||||||
procedure.ProcedureModule = this;
|
procedure.ProcedureService = this;
|
||||||
procedure.Init();
|
procedure.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,14 +114,17 @@ namespace AlicizaX
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
ClearAllProcedures();
|
ClearAllProcedures();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Priority { get; }
|
void IServiceTickable.Tick(float deltaTime)
|
||||||
|
|
||||||
void IModuleUpdate.Update(float elapseSeconds, float realElapseSeconds)
|
|
||||||
{
|
{
|
||||||
if (_currentProcedure != null)
|
if (_currentProcedure != null)
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleSystem.GetModule<IResourceModule>().UnloadAsset(Target);
|
AppServices.Require<IResourceService>().UnloadAsset(Target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,9 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
{
|
{
|
||||||
public partial class ResourceExtComponent
|
public partial class ResourceExtComponent
|
||||||
{
|
{
|
||||||
private static IResourceModule _resourceModule;
|
private static IResourceService _resourceService;
|
||||||
|
|
||||||
public static IResourceModule ResourceModule => _resourceModule;
|
public static IResourceService ResourceService => _resourceService;
|
||||||
|
|
||||||
private class LoadingState : IMemory
|
private class LoadingState : IMemory
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
private void InitializedResources()
|
private void InitializedResources()
|
||||||
{
|
{
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoadAssetSuccess(string assetName, object asset, float duration, object userdata)
|
private void OnLoadAssetSuccess(string assetName, object asset, float duration, object userdata)
|
||||||
@ -62,7 +62,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(assetObject);
|
_resourceService.UnloadAsset(assetObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
T resource = await _resourceModule.LoadAssetAsync<T>(location, linkedTokenSource.Token);
|
T resource = await _resourceService.LoadAssetAsync<T>(location, linkedTokenSource.Token);
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
{
|
{
|
||||||
ClearLoadingState(target);
|
ClearLoadingState(target);
|
||||||
@ -166,7 +166,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
if (_assetItemPool.CanSpawn(location))
|
if (_assetItemPool.CanSpawn(location))
|
||||||
{
|
{
|
||||||
var cachedAsset = _assetItemPool.Spawn(location).Target as UnityEngine.Object;
|
var cachedAsset = _assetItemPool.Spawn(location).Target as UnityEngine.Object;
|
||||||
_resourceModule.UnloadAsset(assetObject);
|
_resourceService.UnloadAsset(assetObject);
|
||||||
return cachedAsset;
|
return cachedAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX.ObjectPool;
|
using AlicizaX.ObjectPool;
|
||||||
@ -66,7 +66,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
yield return new WaitForEndOfFrame();
|
yield return new WaitForEndOfFrame();
|
||||||
IObjectPoolModule objectPoolComponent = ModuleSystem.GetModule<IObjectPoolModule>();
|
IObjectPoolService objectPoolComponent = AppServices.Require<IObjectPoolService>();
|
||||||
_assetItemPool = objectPoolComponent.CreateMultiSpawnObjectPool<AssetItemObject>(
|
_assetItemPool = objectPoolComponent.CreateMultiSpawnObjectPool<AssetItemObject>(
|
||||||
"SetAssetPool",
|
"SetAssetPool",
|
||||||
autoReleaseInterval, 16, 60, 0);
|
autoReleaseInterval, 16, 60, 0);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源管理器接口。
|
/// 资源管理器接口。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IResourceModule : IModule
|
public interface IResourceService : IService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前资源适用的游戏版本号。
|
/// 获取当前资源适用的游戏版本号。
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
@ -28,25 +28,25 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<AssetsRefInfo> refAssetInfoList;
|
private List<AssetsRefInfo> refAssetInfoList;
|
||||||
|
|
||||||
private static IResourceModule _resourceModule;
|
private static IResourceService _resourceService;
|
||||||
private HashSet<int> _refAssetIds;
|
private HashSet<int> _refAssetIds;
|
||||||
|
|
||||||
private bool TryEnsureResourceModule()
|
private bool TryEnsureResourceModule()
|
||||||
{
|
{
|
||||||
if (_resourceModule != null)
|
if (_resourceService != null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
return _resourceModule != null;
|
return _resourceService != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReleaseSourceReference()
|
private void ReleaseSourceReference()
|
||||||
{
|
{
|
||||||
if (sourceGameObject != null)
|
if (sourceGameObject != null)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(sourceGameObject);
|
_resourceService.UnloadAsset(sourceGameObject);
|
||||||
sourceGameObject = null;
|
sourceGameObject = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
{
|
{
|
||||||
foreach (var refInfo in refAssetInfoList)
|
foreach (var refInfo in refAssetInfoList)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(refInfo.refAsset);
|
_resourceService.UnloadAsset(refInfo.refAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
refAssetInfoList.Clear();
|
refAssetInfoList.Clear();
|
||||||
@ -102,7 +102,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
_refAssetIds?.Clear();
|
_refAssetIds?.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetsReference Ref(GameObject source, IResourceModule resourceModule = null)
|
public AssetsReference Ref(GameObject source, IResourceService resourceService = null)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
@ -114,9 +114,9 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
throw new GameFrameworkException($"Source gameObject is in scene.");
|
throw new GameFrameworkException($"Source gameObject is in scene.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceModule != null)
|
if (resourceService != null)
|
||||||
{
|
{
|
||||||
_resourceModule = resourceModule;
|
_resourceService = resourceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceGameObject != null && sourceGameObject != source && TryEnsureResourceModule())
|
if (sourceGameObject != null && sourceGameObject != source && TryEnsureResourceModule())
|
||||||
@ -128,16 +128,16 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetsReference Ref<T>(T source, IResourceModule resourceModule = null) where T : Object
|
public AssetsReference Ref<T>(T source, IResourceService resourceService = null) where T : Object
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
throw new GameFrameworkException($"Source gameObject is null.");
|
throw new GameFrameworkException($"Source gameObject is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceModule != null)
|
if (resourceService != null)
|
||||||
{
|
{
|
||||||
_resourceModule = resourceModule;
|
_resourceService = resourceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureReferenceCache();
|
EnsureReferenceCache();
|
||||||
@ -156,7 +156,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static AssetsReference Instantiate(GameObject source, Transform parent = null, IResourceModule resourceModule = null)
|
internal static AssetsReference Instantiate(GameObject source, Transform parent = null, IResourceService resourceService = null)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
@ -169,10 +169,10 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameObject instance = Object.Instantiate(source, parent);
|
GameObject instance = Object.Instantiate(source, parent);
|
||||||
return instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
return instance.AddComponent<AssetsReference>().Ref(source, resourceService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AssetsReference Ref(GameObject source, GameObject instance, IResourceModule resourceModule = null)
|
public static AssetsReference Ref(GameObject source, GameObject instance, IResourceService resourceService = null)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
@ -185,10 +185,10 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
var comp = instance.GetComponent<AssetsReference>();
|
var comp = instance.GetComponent<AssetsReference>();
|
||||||
return comp ? comp.Ref(source, resourceModule) : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
return comp ? comp.Ref(source, resourceService) : instance.AddComponent<AssetsReference>().Ref(source, resourceService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AssetsReference Ref<T>(T source, GameObject instance, IResourceModule resourceModule = null) where T : Object
|
public static AssetsReference Ref<T>(T source, GameObject instance, IResourceService resourceService = null) where T : Object
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
@ -196,7 +196,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
var comp = instance.GetComponent<AssetsReference>();
|
var comp = instance.GetComponent<AssetsReference>();
|
||||||
return comp ? comp.Ref(source, resourceModule) : instance.AddComponent<AssetsReference>().Ref(source, resourceModule);
|
return comp ? comp.Ref(source, resourceService) : instance.AddComponent<AssetsReference>().Ref(source, resourceService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@ -6,13 +6,13 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
{
|
{
|
||||||
public static class AssetsSetHelper
|
public static class AssetsSetHelper
|
||||||
{
|
{
|
||||||
private static IResourceModule _resourceModule;
|
private static IResourceService _resourceService;
|
||||||
|
|
||||||
private static void CheckResourceManager()
|
private static void CheckResourceManager()
|
||||||
{
|
{
|
||||||
if (_resourceModule == null)
|
if (_resourceService == null)
|
||||||
{
|
{
|
||||||
_resourceModule = ModuleSystem.GetModule<IResourceModule>();
|
_resourceService = AppServices.Require<IResourceService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,17 +29,17 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
if (!isAsync)
|
if (!isAsync)
|
||||||
{
|
{
|
||||||
Material material = _resourceModule.LoadAsset<Material>(location, packageName);
|
Material material = _resourceService.LoadAsset<Material>(location, packageName);
|
||||||
image.material = material;
|
image.material = material;
|
||||||
AssetsReference.Ref(material, image.gameObject);
|
AssetsReference.Ref(material, image.gameObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_resourceModule.LoadAsset<Material>(location, material =>
|
_resourceService.LoadAsset<Material>(location, material =>
|
||||||
{
|
{
|
||||||
if (image == null || image.gameObject == null)
|
if (image == null || image.gameObject == null)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(material);
|
_resourceService.UnloadAsset(material);
|
||||||
material = null;
|
material = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,17 +61,17 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
if (!isAsync)
|
if (!isAsync)
|
||||||
{
|
{
|
||||||
Material material = _resourceModule.LoadAsset<Material>(location, packageName);
|
Material material = _resourceService.LoadAsset<Material>(location, packageName);
|
||||||
spriteRenderer.material = material;
|
spriteRenderer.material = material;
|
||||||
AssetsReference.Ref(material, spriteRenderer.gameObject);
|
AssetsReference.Ref(material, spriteRenderer.gameObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_resourceModule.LoadAsset<Material>(location, material =>
|
_resourceService.LoadAsset<Material>(location, material =>
|
||||||
{
|
{
|
||||||
if (spriteRenderer == null || spriteRenderer.gameObject == null)
|
if (spriteRenderer == null || spriteRenderer.gameObject == null)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(material);
|
_resourceService.UnloadAsset(material);
|
||||||
material = null;
|
material = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,17 +93,17 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
if (!isAsync)
|
if (!isAsync)
|
||||||
{
|
{
|
||||||
Material material = _resourceModule.LoadAsset<Material>(location, packageName);
|
Material material = _resourceService.LoadAsset<Material>(location, packageName);
|
||||||
meshRenderer.material = needInstance ? Object.Instantiate(material) : material;
|
meshRenderer.material = needInstance ? Object.Instantiate(material) : material;
|
||||||
AssetsReference.Ref(material, meshRenderer.gameObject);
|
AssetsReference.Ref(material, meshRenderer.gameObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_resourceModule.LoadAsset<Material>(location, material =>
|
_resourceService.LoadAsset<Material>(location, material =>
|
||||||
{
|
{
|
||||||
if (meshRenderer == null || meshRenderer.gameObject == null)
|
if (meshRenderer == null || meshRenderer.gameObject == null)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(material);
|
_resourceService.UnloadAsset(material);
|
||||||
material = null;
|
material = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,17 +125,17 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
if (!isAsync)
|
if (!isAsync)
|
||||||
{
|
{
|
||||||
Material material = _resourceModule.LoadAsset<Material>(location, packageName);
|
Material material = _resourceService.LoadAsset<Material>(location, packageName);
|
||||||
meshRenderer.sharedMaterial = material;
|
meshRenderer.sharedMaterial = material;
|
||||||
AssetsReference.Ref(material, meshRenderer.gameObject);
|
AssetsReference.Ref(material, meshRenderer.gameObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_resourceModule.LoadAsset<Material>(location, material =>
|
_resourceService.LoadAsset<Material>(location, material =>
|
||||||
{
|
{
|
||||||
if (meshRenderer == null || meshRenderer.gameObject == null)
|
if (meshRenderer == null || meshRenderer.gameObject == null)
|
||||||
{
|
{
|
||||||
_resourceModule.UnloadAsset(material);
|
_resourceService.UnloadAsset(material);
|
||||||
material = null;
|
material = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
private const int DEFAULT_PRIORITY = 0;
|
private const int DEFAULT_PRIORITY = 0;
|
||||||
|
|
||||||
private IResourceModule _resourceModule;
|
private IResourceService _resourceService;
|
||||||
|
|
||||||
private bool _forceUnloadUnusedAssets = false;
|
private bool _forceUnloadUnusedAssets = false;
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前资源适用的游戏版本号。
|
/// 获取当前资源适用的游戏版本号。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ApplicableGameVersion => _resourceModule.ApplicableGameVersion;
|
public string ApplicableGameVersion => _resourceService.ApplicableGameVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前内部资源版本号。
|
/// 获取当前内部资源版本号。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int InternalResourceVersion => _resourceModule.InternalResourceVersion;
|
public int InternalResourceVersion => _resourceService.InternalResourceVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置无用资源释放的最小间隔时间,以秒为单位。
|
/// 获取或设置无用资源释放的最小间隔时间,以秒为单位。
|
||||||
@ -146,8 +146,8 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float AssetAutoReleaseInterval
|
public float AssetAutoReleaseInterval
|
||||||
{
|
{
|
||||||
get => _resourceModule.AssetAutoReleaseInterval;
|
get => _resourceService.AssetAutoReleaseInterval;
|
||||||
set => _resourceModule.AssetAutoReleaseInterval = assetAutoReleaseInterval = value;
|
set => _resourceService.AssetAutoReleaseInterval = assetAutoReleaseInterval = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -155,8 +155,8 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int AssetCapacity
|
public int AssetCapacity
|
||||||
{
|
{
|
||||||
get => _resourceModule.AssetCapacity;
|
get => _resourceService.AssetCapacity;
|
||||||
set => _resourceModule.AssetCapacity = assetCapacity = value;
|
set => _resourceService.AssetCapacity = assetCapacity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -164,8 +164,8 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float AssetExpireTime
|
public float AssetExpireTime
|
||||||
{
|
{
|
||||||
get => _resourceModule.AssetExpireTime;
|
get => _resourceService.AssetExpireTime;
|
||||||
set => _resourceModule.AssetExpireTime = assetExpireTime = value;
|
set => _resourceService.AssetExpireTime = assetExpireTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -173,8 +173,8 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int AssetPriority
|
public int AssetPriority
|
||||||
{
|
{
|
||||||
get => _resourceModule.AssetPriority;
|
get => _resourceService.AssetPriority;
|
||||||
set => _resourceModule.AssetPriority = assetPriority = value;
|
set => _resourceService.AssetPriority = assetPriority = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -191,7 +191,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_resourceModule = ModuleSystem.RegisterModule<IResourceModule, ResourceModule>();
|
_resourceService = AppServices.GetOrCreateScope<AppScope>().Register(new ResourceService());
|
||||||
|
|
||||||
Application.lowMemory += OnLowMemory;
|
Application.lowMemory += OnLowMemory;
|
||||||
}
|
}
|
||||||
@ -201,21 +201,21 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
_playMode = (EPlayMode)UnityEditor.EditorPrefs.GetInt(ResourceComponent.PrefsKey, 0);
|
_playMode = (EPlayMode)UnityEditor.EditorPrefs.GetInt(PrefsKey, 0);
|
||||||
#endif
|
#endif
|
||||||
_resourceModule.DefaultPackageName = PackageName;
|
_resourceService.DefaultPackageName = PackageName;
|
||||||
_resourceModule.DecryptionServices = decryptionServices;
|
_resourceService.DecryptionServices = decryptionServices;
|
||||||
_resourceModule.AutoUnloadBundleWhenUnused = autoUnloadBundleWhenUnused;
|
_resourceService.AutoUnloadBundleWhenUnused = autoUnloadBundleWhenUnused;
|
||||||
_resourceModule.PlayMode = _playMode;
|
_resourceService.PlayMode = _playMode;
|
||||||
_resourceModule.Milliseconds = milliseconds;
|
_resourceService.Milliseconds = milliseconds;
|
||||||
_resourceModule.DownloadingMaxNum = DownloadingMaxNum;
|
_resourceService.DownloadingMaxNum = DownloadingMaxNum;
|
||||||
_resourceModule.FailedTryAgain = FailedTryAgain;
|
_resourceService.FailedTryAgain = FailedTryAgain;
|
||||||
_resourceModule.Initialize();
|
_resourceService.Initialize();
|
||||||
_resourceModule.AssetAutoReleaseInterval = assetAutoReleaseInterval;
|
_resourceService.AssetAutoReleaseInterval = assetAutoReleaseInterval;
|
||||||
_resourceModule.AssetCapacity = assetCapacity;
|
_resourceService.AssetCapacity = assetCapacity;
|
||||||
_resourceModule.AssetExpireTime = assetExpireTime;
|
_resourceService.AssetExpireTime = assetExpireTime;
|
||||||
_resourceModule.AssetPriority = assetPriority;
|
_resourceService.AssetPriority = assetPriority;
|
||||||
_resourceModule.SetForceUnloadUnusedAssetsAction(ForceUnloadUnusedAssets);
|
_resourceService.SetForceUnloadUnusedAssetsAction(ForceUnloadUnusedAssets);
|
||||||
Log.Info($"ResourceModule Run Mode:{_playMode}");
|
Log.Info($"ResourceModule Run Mode:{_playMode}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
_forceUnloadUnusedAssets = false;
|
_forceUnloadUnusedAssets = false;
|
||||||
_preorderUnloadUnusedAssets = false;
|
_preorderUnloadUnusedAssets = false;
|
||||||
_lastUnloadUnusedAssetsOperationElapseSeconds = 0f;
|
_lastUnloadUnusedAssetsOperationElapseSeconds = 0f;
|
||||||
_resourceModule.UnloadUnusedAssets();
|
_resourceService.UnloadUnusedAssets();
|
||||||
_asyncOperation = useSystemUnloadUnusedAssets ? Resources.UnloadUnusedAssets() : null;
|
_asyncOperation = useSystemUnloadUnusedAssets ? Resources.UnloadUnusedAssets() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,9 +286,9 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
private void OnLowMemory()
|
private void OnLowMemory()
|
||||||
{
|
{
|
||||||
Log.Warning("Low memory reported...");
|
Log.Warning("Low memory reported...");
|
||||||
if (_resourceModule != null)
|
if (_resourceService != null)
|
||||||
{
|
{
|
||||||
_resourceModule.OnLowMemory();
|
_resourceService.OnLowMemory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX.ObjectPool;
|
using AlicizaX.ObjectPool;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
@ -6,7 +6,7 @@ using YooAsset;
|
|||||||
|
|
||||||
namespace AlicizaX.Resource.Runtime
|
namespace AlicizaX.Resource.Runtime
|
||||||
{
|
{
|
||||||
internal partial class ResourceModule
|
internal partial class ResourceService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象。
|
/// 资源对象。
|
||||||
@ -14,7 +14,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
private sealed class AssetObject : ObjectBase
|
private sealed class AssetObject : ObjectBase
|
||||||
{
|
{
|
||||||
private AssetHandle m_AssetHandle;
|
private AssetHandle m_AssetHandle;
|
||||||
private ResourceModule _mResourceModule;
|
private IResourceService _resourceService;
|
||||||
|
|
||||||
|
|
||||||
public AssetObject()
|
public AssetObject()
|
||||||
@ -22,14 +22,14 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
m_AssetHandle = null;
|
m_AssetHandle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AssetObject Create(string name, object target, object assetHandle, ResourceModule resourceModule)
|
public static AssetObject Create(string name, object target, object assetHandle, IResourceService resourceService)
|
||||||
{
|
{
|
||||||
if (assetHandle == null)
|
if (assetHandle == null)
|
||||||
{
|
{
|
||||||
throw new GameFrameworkException("Resource is invalid.");
|
throw new GameFrameworkException("Resource is invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resourceModule == null)
|
if (resourceService == null)
|
||||||
{
|
{
|
||||||
throw new GameFrameworkException("Resource Manager is invalid.");
|
throw new GameFrameworkException("Resource Manager is invalid.");
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
AssetObject assetObject = MemoryPool.Acquire<AssetObject>();
|
AssetObject assetObject = MemoryPool.Acquire<AssetObject>();
|
||||||
assetObject.Initialize(name, target);
|
assetObject.Initialize(name, target);
|
||||||
assetObject.m_AssetHandle = (AssetHandle)assetHandle;
|
assetObject.m_AssetHandle = (AssetHandle)assetHandle;
|
||||||
assetObject._mResourceModule = resourceModule;
|
assetObject._resourceService = resourceService;
|
||||||
return assetObject;
|
return assetObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4,7 +4,7 @@ using YooAsset;
|
|||||||
|
|
||||||
namespace AlicizaX.Resource.Runtime
|
namespace AlicizaX.Resource.Runtime
|
||||||
{
|
{
|
||||||
internal partial class ResourceModule
|
internal partial class ResourceService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据运行模式创建初始化操作数据
|
/// 根据运行模式创建初始化操作数据
|
||||||
@ -1,9 +1,9 @@
|
|||||||
using AlicizaX.ObjectPool;
|
using AlicizaX.ObjectPool;
|
||||||
using AlicizaX;
|
using AlicizaX;
|
||||||
|
|
||||||
namespace AlicizaX.Resource.Runtime
|
namespace AlicizaX.Resource.Runtime
|
||||||
{
|
{
|
||||||
internal partial class ResourceModule
|
internal partial class ResourceService
|
||||||
{
|
{
|
||||||
private IObjectPool<AssetObject> _assetPool;
|
private IObjectPool<AssetObject> _assetPool;
|
||||||
|
|
||||||
@ -59,13 +59,9 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// 设置对象池管理器。
|
/// 设置对象池管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectPoolModule">对象池管理器。</param>
|
/// <param name="objectPoolModule">对象池管理器。</param>
|
||||||
public void SetObjectPoolModule(IObjectPoolModule objectPoolModule)
|
public void CreateAssetPool( )
|
||||||
{
|
{
|
||||||
if (objectPoolModule == null)
|
_assetPool = Context.Require<IObjectPoolService>().CreateMultiSpawnObjectPool<AssetObject>("Asset Pool");
|
||||||
{
|
|
||||||
throw new GameFrameworkException("Object pool manager is invalid.");
|
|
||||||
}
|
|
||||||
_assetPool = objectPoolModule.CreateMultiSpawnObjectPool<AssetObject>("Asset Pool");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -13,7 +13,7 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源管理器。
|
/// 资源管理器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed partial class ResourceModule : IResourceModule
|
internal sealed partial class ResourceService : ServiceBase, IResourceService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认资源包名称。
|
/// 默认资源包名称。
|
||||||
@ -111,12 +111,15 @@ namespace AlicizaX.Resource.Runtime
|
|||||||
DefaultPackage = defaultPackage;
|
DefaultPackage = defaultPackage;
|
||||||
PackageMap[packageName] = defaultPackage;
|
PackageMap[packageName] = defaultPackage;
|
||||||
|
|
||||||
IObjectPoolModule objectPoolModule = ModuleSystem.GetModule<IObjectPoolModule>();
|
CreateAssetPool();
|
||||||
SetObjectPoolModule(objectPoolModule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IModule.Dispose()
|
protected override void OnInitialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
foreach (var loadingOperation in _assetLoadingOperations.Values)
|
foreach (var loadingOperation in _assetLoadingOperations.Values)
|
||||||
{
|
{
|
||||||
@ -7,7 +7,7 @@ using YooAsset;
|
|||||||
|
|
||||||
namespace AlicizaX.Scene.Runtime
|
namespace AlicizaX.Scene.Runtime
|
||||||
{
|
{
|
||||||
public interface ISceneModule : IModule,IModuleAwake
|
public interface ISceneService : IService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前主场景名称。
|
/// 当前主场景名称。
|
||||||
@ -10,7 +10,7 @@ namespace AlicizaX.Scene.Runtime
|
|||||||
{
|
{
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
ModuleSystem.RegisterModule<ISceneModule,SceneModule>();
|
AppServices.GetOrCreateScope<AppScope>().Register(new SceneService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using YooAsset;
|
|||||||
|
|
||||||
namespace AlicizaX.Scene.Runtime
|
namespace AlicizaX.Scene.Runtime
|
||||||
{
|
{
|
||||||
internal class SceneModule : ISceneModule
|
internal class SceneService : ServiceBase, ISceneService
|
||||||
{
|
{
|
||||||
private string _currentMainSceneName = string.Empty;
|
private string _currentMainSceneName = string.Empty;
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ namespace AlicizaX.Scene.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string CurrentMainSceneName => _currentMainSceneName;
|
public string CurrentMainSceneName => _currentMainSceneName;
|
||||||
|
|
||||||
void IModuleAwake.Awake()
|
protected override void OnInitialize()
|
||||||
{
|
{
|
||||||
_currentMainScene = null;
|
_currentMainScene = null;
|
||||||
_currentMainSceneName = SceneManager.GetSceneByBuildIndex(0).name;
|
_currentMainSceneName = SceneManager.GetSceneByBuildIndex(0).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IModule.Dispose()
|
protected override void OnDestroyService()
|
||||||
{
|
{
|
||||||
var iter = _subScenes.Values.GetEnumerator();
|
var iter = _subScenes.Values.GetEnumerator();
|
||||||
while (iter.MoveNext())
|
while (iter.MoveNext())
|
||||||
@ -117,7 +117,7 @@ namespace AlicizaX.Scene.Runtime
|
|||||||
await _currentMainScene.ToUniTask();
|
await _currentMainScene.ToUniTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleSystem.GetModule<IResourceModule>().ForceUnloadUnusedAssets(gcCollect);
|
Context.Require<IResourceService>().ForceUnloadUnusedAssets(gcCollect);
|
||||||
|
|
||||||
_handlingScene.Remove(location);
|
_handlingScene.Remove(location);
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ namespace AlicizaX.Scene.Runtime
|
|||||||
InvokeProgress(_currentMainScene, progressCallBack).Forget();
|
InvokeProgress(_currentMainScene, progressCallBack).Forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleSystem.GetModule<IResourceModule>().ForceUnloadUnusedAssets(gcCollect);
|
Context.Require<IResourceService>().ForceUnloadUnusedAssets(gcCollect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using AlicizaX;
|
|
||||||
|
|
||||||
namespace AlicizaX
|
namespace AlicizaX
|
||||||
{
|
{
|
||||||
[UnityEngine.Scripting.Preserve]
|
[UnityEngine.Scripting.Preserve]
|
||||||
public interface ITimerModule : IModule, IModuleUpdate
|
public interface ITimerService : IService, IServiceTickable
|
||||||
{
|
{
|
||||||
int AddTimer(TimerHandler callback, float time, bool isLoop = false, bool isUnscaled = false, params object[] args);
|
int AddTimer(TimerHandler callback, float time, bool isLoop = false, bool isUnscaled = false, params object[] args);
|
||||||
int AddTimer(TimerHandlerNoArgs callback, float time, bool isLoop = false, bool isUnscaled = false);
|
int AddTimer(TimerHandlerNoArgs callback, float time, bool isLoop = false, bool isUnscaled = false);
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user