mirror of https://github.com/tuyoogame/YooAsset
update space shooter
parent
ff8f8623d9
commit
20061983d6
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
using UniFramework.Event;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
public class Boot : MonoBehaviour
|
||||
|
@ -21,15 +21,15 @@ public class Boot : MonoBehaviour
|
|||
// 初始化事件系统
|
||||
UniEvent.Initalize();
|
||||
|
||||
// 初始化管理系统
|
||||
UniModule.Initialize();
|
||||
// 初始化单例系统
|
||||
UniSingleton.Initialize();
|
||||
|
||||
// 初始化资源系统
|
||||
YooAssets.Initialize();
|
||||
YooAssets.SetOperationSystemMaxTimeSlice(30);
|
||||
|
||||
// 创建补丁管理器
|
||||
UniModule.CreateModule<PatchManager>();
|
||||
UniSingleton.CreateSingleton<PatchManager>();
|
||||
|
||||
// 开始补丁更新流程
|
||||
PatchManager.Instance.Run(PlayMode);
|
||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
|||
using UniFramework.Pooling;
|
||||
using UniFramework.Window;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
internal class FsmInitGame : IStateNode
|
||||
|
@ -17,7 +17,7 @@ internal class FsmInitGame : IStateNode
|
|||
}
|
||||
void IStateNode.OnEnter()
|
||||
{
|
||||
UniModule.StartCoroutine(Prepare());
|
||||
UniSingleton.StartCoroutine(Prepare());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
|||
using UniFramework.Window;
|
||||
using UniFramework.Event;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
internal class FsmSceneBattle : IStateNode
|
||||
|
@ -17,7 +17,7 @@ internal class FsmSceneBattle : IStateNode
|
|||
}
|
||||
void IStateNode.OnEnter()
|
||||
{
|
||||
UniModule.StartCoroutine(Prepare());
|
||||
UniSingleton.StartCoroutine(Prepare());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Window;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
internal class FsmSceneHome : IStateNode
|
||||
|
@ -16,7 +16,7 @@ internal class FsmSceneHome : IStateNode
|
|||
}
|
||||
void IStateNode.OnEnter()
|
||||
{
|
||||
UniModule.StartCoroutine(Prepare());
|
||||
UniSingleton.StartCoroutine(Prepare());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -3,22 +3,22 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UniFramework.Event;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
|
||||
public class GameManager : ModuleSingleton<GameManager>, IModule
|
||||
public class GameManager : SingletonInstance<GameManager>, ISingleton
|
||||
{
|
||||
private bool _isRun = false;
|
||||
private EventGroup _eventGroup = new EventGroup();
|
||||
private StateMachine _machine;
|
||||
|
||||
void IModule.OnCreate(object createParam)
|
||||
void ISingleton.OnCreate(object createParam)
|
||||
{
|
||||
}
|
||||
void IModule.OnDestroy()
|
||||
void ISingleton.OnDestroy()
|
||||
{
|
||||
_eventGroup.RemoveAllListener();
|
||||
}
|
||||
void IModule.OnUpdate()
|
||||
void ISingleton.OnUpdate()
|
||||
{
|
||||
if (_machine != null)
|
||||
_machine.Update();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,7 +19,7 @@ public class FsmCreateDownloader : IStateNode
|
|||
void IStateNode.OnEnter()
|
||||
{
|
||||
PatchEventDefine.PatchStatesChange.SendEventMessage("创建补丁下载器!");
|
||||
UniModule.StartCoroutine(CreateDownloader());
|
||||
UniSingleton.StartCoroutine(CreateDownloader());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
@ -18,7 +18,7 @@ public class FsmDownloadFiles : IStateNode
|
|||
void IStateNode.OnEnter()
|
||||
{
|
||||
PatchEventDefine.PatchStatesChange.SendEventMessage("开始下载补丁文件!");
|
||||
UniModule.StartCoroutine(BeginDownload());
|
||||
UniSingleton.StartCoroutine(BeginDownload());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
@ -21,7 +21,7 @@ internal class FsmInitialize : IStateNode
|
|||
void IStateNode.OnEnter()
|
||||
{
|
||||
PatchEventDefine.PatchStatesChange.SendEventMessage("初始化资源包!");
|
||||
UniModule.StartCoroutine(InitPackage());
|
||||
UniSingleton.StartCoroutine(InitPackage());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
|
||||
/// <summary>
|
||||
/// 流程更新完毕
|
||||
|
@ -17,7 +17,7 @@ internal class FsmPatchDone : IStateNode
|
|||
PatchEventDefine.PatchStatesChange.SendEventMessage("开始游戏!");
|
||||
|
||||
// 创建游戏管理器
|
||||
UniModule.CreateModule<GameManager>();
|
||||
UniSingleton.CreateSingleton<GameManager>();
|
||||
|
||||
// 开启游戏流程
|
||||
GameManager.Instance.Run();
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
|
||||
/// <summary>
|
||||
/// 流程准备工作
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,7 +19,7 @@ public class FsmUpdateManifest : IStateNode
|
|||
void IStateNode.OnEnter()
|
||||
{
|
||||
PatchEventDefine.PatchStatesChange.SendEventMessage("更新资源清单!");
|
||||
UniModule.StartCoroutine(UpdateManifest());
|
||||
UniSingleton.StartCoroutine(UpdateManifest());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,7 +19,7 @@ internal class FsmUpdateVersion : IStateNode
|
|||
void IStateNode.OnEnter()
|
||||
{
|
||||
PatchEventDefine.PatchStatesChange.SendEventMessage("获取最新的资源版本 !");
|
||||
UniModule.StartCoroutine(GetStaticVersion());
|
||||
UniSingleton.StartCoroutine(GetStaticVersion());
|
||||
}
|
||||
void IStateNode.OnUpdate()
|
||||
{
|
||||
|
|
|
@ -4,10 +4,10 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UniFramework.Machine;
|
||||
using UniFramework.Event;
|
||||
using UniFramework.Module;
|
||||
using UniFramework.Singleton;
|
||||
using YooAsset;
|
||||
|
||||
public class PatchManager : ModuleSingleton<PatchManager>, IModule
|
||||
public class PatchManager : SingletonInstance<PatchManager>, ISingleton
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行模式
|
||||
|
@ -29,14 +29,14 @@ public class PatchManager : ModuleSingleton<PatchManager>, IModule
|
|||
private EventGroup _eventGroup = new EventGroup();
|
||||
private StateMachine _machine;
|
||||
|
||||
void IModule.OnCreate(object createParam)
|
||||
void ISingleton.OnCreate(object createParam)
|
||||
{
|
||||
}
|
||||
void IModule.OnDestroy()
|
||||
void ISingleton.OnDestroy()
|
||||
{
|
||||
_eventGroup.RemoveAllListener();
|
||||
}
|
||||
void IModule.OnUpdate()
|
||||
void ISingleton.OnUpdate()
|
||||
{
|
||||
if (_machine != null)
|
||||
_machine.Update();
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
# UniFramework.Module
|
||||
|
||||
一个轻量级的模块系统。
|
|
@ -1,12 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UniFramework.Module
|
||||
{
|
||||
internal class UniModuleDriver : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
UniModule.Update();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -65,10 +65,10 @@ namespace UniFramework.Pooling
|
|||
/// <summary>
|
||||
/// 创建对象池
|
||||
/// </summary>
|
||||
public void CreatePool(AssetsPackage assetPackage)
|
||||
public void CreatePool(ResourcePackage package)
|
||||
{
|
||||
// 加载游戏对象
|
||||
AssetHandle = assetPackage.LoadAssetAsync<GameObject>(Location);
|
||||
AssetHandle = package.LoadAssetAsync<GameObject>(Location);
|
||||
|
||||
// 创建初始对象
|
||||
for (int i = 0; i < _initCapacity; i++)
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace UniFramework.Pooling
|
|||
private readonly List<GameObjectPool> _gameObjectPools = new List<GameObjectPool>(100);
|
||||
private readonly List<GameObjectPool> _removeList = new List<GameObjectPool>(100);
|
||||
private readonly GameObject _spawnerRoot;
|
||||
private readonly AssetsPackage _assetPackage;
|
||||
private readonly ResourcePackage _package;
|
||||
|
||||
public string PackageName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _assetPackage.PackageName;
|
||||
return _package.PackageName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ namespace UniFramework.Pooling
|
|||
private Spawner()
|
||||
{
|
||||
}
|
||||
internal Spawner(GameObject poolingRoot, AssetsPackage assetPackage)
|
||||
internal Spawner(GameObject poolingRoot, ResourcePackage package)
|
||||
{
|
||||
_spawnerRoot = new GameObject($"{assetPackage.PackageName}");
|
||||
_spawnerRoot = new GameObject($"{package.PackageName}");
|
||||
_spawnerRoot.transform.SetParent(poolingRoot.transform);
|
||||
_assetPackage = assetPackage;
|
||||
_package = package;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -137,7 +137,7 @@ namespace UniFramework.Pooling
|
|||
else
|
||||
{
|
||||
pool = new GameObjectPool(_spawnerRoot, location, dontDestroy, initCapacity, maxCapacity, destroyTime);
|
||||
pool.CreatePool(_assetPackage);
|
||||
pool.CreatePool(_package);
|
||||
_gameObjectPools.Add(pool);
|
||||
|
||||
var operation = new CreatePoolOperation(pool.AssetHandle);
|
||||
|
@ -240,7 +240,7 @@ namespace UniFramework.Pooling
|
|||
|
||||
// 如果不存在创建游戏对象池
|
||||
pool = new GameObjectPool(_spawnerRoot, location, false, 0, int.MaxValue, -1f);
|
||||
pool.CreatePool(_assetPackage);
|
||||
pool.CreatePool(_package);
|
||||
_gameObjectPools.Add(pool);
|
||||
return pool.Spawn(parent, position, rotation, forceClone, userDatas);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace UniFramework.Pooling
|
|||
public static Spawner CreateSpawner(string packageName)
|
||||
{
|
||||
// 获取资源包
|
||||
var assetPackage = YooAssets.GetAssetsPackage(packageName);
|
||||
var assetPackage = YooAssets.GetPackage(packageName);
|
||||
if (assetPackage == null)
|
||||
throw new Exception($"Not found asset package : {packageName}");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4e57ebf0b48a9d94dba1c0ce723da392
|
||||
guid: c4d0461b6228c584dab24fbeb8dc4907
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
3
Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniSingleton/README.md
vendored
Normal file
3
Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniSingleton/README.md
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# UniFramework.Singleton
|
||||
|
||||
一个轻量级的单例系统。
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
namespace UniFramework.Module
|
||||
namespace UniFramework.Singleton
|
||||
{
|
||||
public interface IModule
|
||||
public interface ISingleton
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建模块
|
||||
/// 创建单例
|
||||
/// </summary>
|
||||
void OnCreate(System.Object createParam);
|
||||
|
||||
/// <summary>
|
||||
/// 更新模块
|
||||
/// 更新单例
|
||||
/// </summary>
|
||||
void OnUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// 销毁模块
|
||||
/// 销毁单例
|
||||
/// </summary>
|
||||
void OnDestroy();
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace UniFramework.Module
|
||||
namespace UniFramework.Singleton
|
||||
{
|
||||
public abstract class ModuleSingleton<T> where T : class, IModule
|
||||
public abstract class SingletonInstance<T> where T : class, ISingleton
|
||||
{
|
||||
private static T _instance;
|
||||
public static T Instance
|
||||
|
@ -9,18 +9,18 @@ namespace UniFramework.Module
|
|||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
UniLogger.Error($"{typeof(T)} is not create. Use {nameof(UniModule)}.{nameof(UniModule.CreateModule)} create.");
|
||||
UniLogger.Error($"{typeof(T)} is not create. Use {nameof(UniSingleton)}.{nameof(UniSingleton.CreateSingleton)} create.");
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
protected ModuleSingleton()
|
||||
protected SingletonInstance()
|
||||
{
|
||||
if (_instance != null)
|
||||
throw new System.Exception($"{typeof(T)} instance already created.");
|
||||
_instance = this as T;
|
||||
}
|
||||
protected void DestroySingleton()
|
||||
protected void DestroyInstance()
|
||||
{
|
||||
_instance = null;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b6c8230c0d097534e950f4e84ce01e96
|
||||
guid: 9b334be14d2a937409f5e47373f819c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -1,6 +1,6 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace UniFramework.Module
|
||||
namespace UniFramework.Singleton
|
||||
{
|
||||
internal static class UniLogger
|
||||
{
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "UniModule",
|
||||
"name": "UniSingleton",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:e34a5702dd353724aa315fb8011f08c3"
|
|
@ -3,18 +3,18 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniFramework.Module
|
||||
namespace UniFramework.Singleton
|
||||
{
|
||||
public static class UniModule
|
||||
public static class UniSingleton
|
||||
{
|
||||
private class Wrapper
|
||||
{
|
||||
public int Priority { private set; get; }
|
||||
public IModule Module { private set; get; }
|
||||
public ISingleton Singleton { private set; get; }
|
||||
|
||||
public Wrapper(IModule module, int priority)
|
||||
public Wrapper(ISingleton module, int priority)
|
||||
{
|
||||
Module = module;
|
||||
Singleton = module;
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
||||
|
@ -26,26 +26,26 @@ namespace UniFramework.Module
|
|||
private static bool _isDirty = false;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化模块系统
|
||||
/// 初始化单例系统
|
||||
/// </summary>
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception($"{nameof(UniModule)} is initialized !");
|
||||
throw new Exception($"{nameof(UniSingleton)} is initialized !");
|
||||
|
||||
if (_isInitialize == false)
|
||||
{
|
||||
// 创建驱动器
|
||||
_isInitialize = true;
|
||||
_driver = new UnityEngine.GameObject($"[{nameof(UniModule)}]");
|
||||
_behaviour = _driver.AddComponent<UniModuleDriver>();
|
||||
_driver = new UnityEngine.GameObject($"[{nameof(UniSingleton)}]");
|
||||
_behaviour = _driver.AddComponent<UniSingletonDriver>();
|
||||
UnityEngine.Object.DontDestroyOnLoad(_driver);
|
||||
UniLogger.Log($"{nameof(UniModule)} initalize !");
|
||||
UniLogger.Log($"{nameof(UniSingleton)} initalize !");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁模块系统
|
||||
/// 销毁单例系统
|
||||
/// </summary>
|
||||
public static void Destroy()
|
||||
{
|
||||
|
@ -56,12 +56,12 @@ namespace UniFramework.Module
|
|||
_isInitialize = false;
|
||||
if (_driver != null)
|
||||
GameObject.Destroy(_driver);
|
||||
UniLogger.Log($"{nameof(UniModule)} destroy all !");
|
||||
UniLogger.Log($"{nameof(UniSingleton)} destroy all !");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新模块系统
|
||||
/// 更新单例系统
|
||||
/// </summary>
|
||||
internal static void Update()
|
||||
{
|
||||
|
@ -83,20 +83,20 @@ namespace UniFramework.Module
|
|||
// 轮询所有模块
|
||||
for (int i = 0; i < _wrappers.Count; i++)
|
||||
{
|
||||
_wrappers[i].Module.OnUpdate();
|
||||
_wrappers[i].Singleton.OnUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取模块
|
||||
/// 获取单例
|
||||
/// </summary>
|
||||
public static T GetModule<T>() where T : class, IModule
|
||||
public static T GetSingleton<T>() where T : class, ISingleton
|
||||
{
|
||||
System.Type type = typeof(T);
|
||||
for (int i = 0; i < _wrappers.Count; i++)
|
||||
{
|
||||
if (_wrappers[i].Module.GetType() == type)
|
||||
return _wrappers[i].Module as T;
|
||||
if (_wrappers[i].Singleton.GetType() == type)
|
||||
return _wrappers[i].Singleton as T;
|
||||
}
|
||||
|
||||
UniLogger.Error($"Not found manager : {type}");
|
||||
|
@ -104,34 +104,34 @@ namespace UniFramework.Module
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询模块是否存在
|
||||
/// 查询单例是否存在
|
||||
/// </summary>
|
||||
public static bool Contains<T>() where T : class, IModule
|
||||
public static bool Contains<T>() where T : class, ISingleton
|
||||
{
|
||||
System.Type type = typeof(T);
|
||||
for (int i = 0; i < _wrappers.Count; i++)
|
||||
{
|
||||
if (_wrappers[i].Module.GetType() == type)
|
||||
if (_wrappers[i].Singleton.GetType() == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建模块
|
||||
/// 创建单例
|
||||
/// </summary>
|
||||
/// <param name="priority">运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行</param>
|
||||
public static T CreateModule<T>(int priority = 0) where T : class, IModule
|
||||
public static T CreateSingleton<T>(int priority = 0) where T : class, ISingleton
|
||||
{
|
||||
return CreateModule<T>(null, priority);
|
||||
return CreateSingleton<T>(null, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建模块
|
||||
/// 创建单例
|
||||
/// </summary>
|
||||
/// <param name="createParam">附加参数</param>
|
||||
/// <param name="priority">运行时的优先级,优先级越大越早执行。如果没有设置优先级,那么会按照添加顺序执行</param>
|
||||
public static T CreateModule<T>(System.Object createParam, int priority = 0) where T : class, IModule
|
||||
public static T CreateSingleton<T>(System.Object createParam, int priority = 0) where T : class, ISingleton
|
||||
{
|
||||
if (priority < 0)
|
||||
throw new Exception("The priority can not be negative");
|
||||
|
@ -148,23 +148,23 @@ namespace UniFramework.Module
|
|||
|
||||
T module = Activator.CreateInstance<T>();
|
||||
Wrapper wrapper = new Wrapper(module, priority);
|
||||
wrapper.Module.OnCreate(createParam);
|
||||
wrapper.Singleton.OnCreate(createParam);
|
||||
_wrappers.Add(wrapper);
|
||||
_isDirty = true;
|
||||
return module;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁模块
|
||||
/// 销毁单例
|
||||
/// </summary>
|
||||
public static bool DestroyModule<T>() where T : class, IModule
|
||||
public static bool DestroySingleton<T>() where T : class, ISingleton
|
||||
{
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < _wrappers.Count; i++)
|
||||
{
|
||||
if (_wrappers[i].Module.GetType() == type)
|
||||
if (_wrappers[i].Singleton.GetType() == type)
|
||||
{
|
||||
_wrappers[i].Module.OnDestroy();
|
||||
_wrappers[i].Singleton.OnDestroy();
|
||||
_wrappers.RemoveAt(i);
|
||||
return true;
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ namespace UniFramework.Module
|
|||
{
|
||||
for (int i = 0; i < _wrappers.Count; i++)
|
||||
{
|
||||
_wrappers[i].Module.OnDestroy();
|
||||
_wrappers[i].Singleton.OnDestroy();
|
||||
}
|
||||
_wrappers.Clear();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UniFramework.Singleton
|
||||
{
|
||||
internal class UniSingletonDriver : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
UniSingleton.Update();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue