diff --git a/Assets/YooAsset/Samples~/Space Shooter/Boot.unity b/Assets/YooAsset/Samples~/Space Shooter/Boot.unity index 0531645..2dcf963 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/Boot.unity +++ b/Assets/YooAsset/Samples~/Space Shooter/Boot.unity @@ -121,6 +121,49 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &1096367106 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1096367108} + - component: {fileID: 1096367107} + m_Layer: 0 + m_Name: Application + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1096367107 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1096367106} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3cbcea01819f3d94ba5162624ad9c75f, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1096367108 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1096367106} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.8017086, y: 0, z: 16.699955} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1281760859 GameObject: m_ObjectHideFlags: 0 @@ -150,7 +193,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 41fef9a778e4e254b939e9dc3e553bf0, type: 3} m_Name: m_EditorClassIdentifier: - PlayMode: 1 + PlayMode: 2 --- !u!4 &1281760861 Transform: m_ObjectHideFlags: 0 @@ -163,7 +206,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &6920458660802423023 GameObject: diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs new file mode 100644 index 0000000..f318513 --- /dev/null +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs @@ -0,0 +1,15 @@ +using System; +using UnityEngine; +using YooAsset; + +public class BhvApplicationQuit : MonoBehaviour +{ + private void Awake() + { + DontDestroyOnLoad(this.gameObject); + } + private void OnApplicationQuit() + { + YooAssets.Destroy(); + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs.meta b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs.meta new file mode 100644 index 0000000..f6a262d --- /dev/null +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Behaviour/BhvApplicationQuit.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3cbcea01819f3d94ba5162624ad9c75f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneBattle.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneBattle.cs index 3f8fba3..8dc0864 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneBattle.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneBattle.cs @@ -17,8 +17,6 @@ internal class FsmSceneBattle : IStateNode } void IStateNode.OnEnter() { - UniWindow.OpenWindowSync("UILoading"); - UniModule.StartCoroutine(Prepare()); } void IStateNode.OnUpdate() @@ -37,6 +35,7 @@ internal class FsmSceneBattle : IStateNode private IEnumerator Prepare() { + yield return UniWindow.OpenWindowAsync("UILoading"); yield return YooAssets.LoadSceneAsync("scene_battle"); _battleRoom = new BattleRoom(); diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneHome.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneHome.cs index 3260bef..b3c1b1e 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneHome.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/GameLogic/FsmNode/FsmSceneHome.cs @@ -16,9 +16,6 @@ internal class FsmSceneHome : IStateNode } void IStateNode.OnEnter() { - if (_machine.PreviousNode != typeof(FsmInitGame).FullName) - UniWindow.OpenWindowSync("UILoading"); - UniModule.StartCoroutine(Prepare()); } void IStateNode.OnUpdate() @@ -31,6 +28,9 @@ internal class FsmSceneHome : IStateNode private IEnumerator Prepare() { + if (_machine.PreviousNode != typeof(FsmInitGame).FullName) + yield return UniWindow.OpenWindowAsync("UILoading"); + yield return YooAssets.LoadSceneAsync("scene_home"); yield return UniWindow.OpenWindowAsync("UIHome"); yield return new WaitForSeconds(0.5f); diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmCreateDownloader.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmCreateDownloader.cs index 632e85c..e658890 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmCreateDownloader.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/PatchLogic/FsmNode/FsmCreateDownloader.cs @@ -39,12 +39,13 @@ public class FsmCreateDownloader : IStateNode if (downloader.TotalDownloadCount == 0) { - Debug.Log("没有发现需要下载的资源!"); + Debug.Log("Not found any download files !"); _machine.ChangeState(); } else { - Debug.Log($"一共发现了{downloader.TotalDownloadCount}个资源需要更新下载!"); + //A total of 10 files were found that need to be downloaded + Debug.Log($"Found total {downloader.TotalDownloadCount} files that need download !"); // 发现新更新文件后,挂起流程系统 // 注意:开发者需要在下载前检测磁盘空间不足 diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEvent.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEvent.cs index 32c7293..ae04855 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEvent.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEvent.cs @@ -22,6 +22,7 @@ namespace UniFramework.Event } private static bool _isInitialize = false; + private static GameObject _driver = null; private static readonly Dictionary>> _listeners = new Dictionary>>(1000); private static readonly List _postingList = new List(1000); @@ -37,9 +38,26 @@ namespace UniFramework.Event { // 创建驱动器 _isInitialize = true; - GameObject driver = new UnityEngine.GameObject($"[{nameof(UniEvent)}]"); - driver.AddComponent(); - UnityEngine.Object.DontDestroyOnLoad(driver); + _driver = new UnityEngine.GameObject($"[{nameof(UniEvent)}]"); + _driver.AddComponent(); + UnityEngine.Object.DontDestroyOnLoad(_driver); + UniLogger.Log($"{nameof(UniEvent)} initalize !"); + } + } + + /// + /// 销毁事件系统 + /// + public static void Destroy() + { + if (_isInitialize) + { + ClearAll(); + + _isInitialize = false; + if (_driver != null) + GameObject.Destroy(_driver); + UniLogger.Log($"{nameof(UniEvent)} destroy all !"); } } @@ -59,21 +77,6 @@ namespace UniFramework.Event } } - /// - /// 销毁事件系统 - /// - internal static void Destroy() - { - if (_isInitialize) - { - _isInitialize = false; - ClearAll(); - - UniLogger.Log($"{nameof(UniEvent)} destroy all !"); - } - } - - /// /// 清空所有监听 /// diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEventDriver.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEventDriver.cs index f0cd255..62d717a 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEventDriver.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniEvent/Runtime/UniEventDriver.cs @@ -8,10 +8,5 @@ namespace UniFramework.Event { UniEvent.Update(); } - - void OnDestroy() - { - UniEvent.Destroy(); - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/README.md b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/README.md index 03c233c..3c10c7d 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/README.md +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/README.md @@ -1,3 +1,3 @@ -# UniFramework.Event +# UniFramework.Machine 一个轻量级的状态机。 diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/IStateNode.cs.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/IStateNode.cs.meta index 6d8c6a1..2d5a76a 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/IStateNode.cs.meta +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/IStateNode.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 19d466eecc32f6a478d64f6a78748b23 +guid: 40fe73297598be84fb8dadedd4dd17e6 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/StateMachine.cs.meta b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/StateMachine.cs.meta index 4785e08..a63a247 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/StateMachine.cs.meta +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniMachine/Runtime/StateMachine.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5999045dd15678e4bbaca21f460ea0e6 +guid: bcbf86a86eb115a41b6aa61fb0945d43 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModule.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModule.cs index a688fc2..79dd206 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModule.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModule.cs @@ -20,6 +20,7 @@ namespace UniFramework.Module } private static bool _isInitialize = false; + private static GameObject _driver = null; private static readonly List _wrappers = new List(100); private static MonoBehaviour _behaviour; private static bool _isDirty = false; @@ -36,9 +37,26 @@ namespace UniFramework.Module { // 创建驱动器 _isInitialize = true; - GameObject driver = new UnityEngine.GameObject($"[{nameof(UniModule)}]"); - _behaviour = driver.AddComponent(); - UnityEngine.Object.DontDestroyOnLoad(driver); + _driver = new UnityEngine.GameObject($"[{nameof(UniModule)}]"); + _behaviour = _driver.AddComponent(); + UnityEngine.Object.DontDestroyOnLoad(_driver); + UniLogger.Log($"{nameof(UniModule)} initalize !"); + } + } + + /// + /// 销毁模块系统 + /// + public static void Destroy() + { + if (_isInitialize) + { + DestroyAll(); + + _isInitialize = false; + if (_driver != null) + GameObject.Destroy(_driver); + UniLogger.Log($"{nameof(UniModule)} destroy all !"); } } @@ -69,20 +87,6 @@ namespace UniFramework.Module } } - /// - /// 销毁模块系统 - /// - internal static void Destroy() - { - if (_isInitialize) - { - _isInitialize = false; - DestroyAll(); - - UniLogger.Log($"{nameof(UniModule)} destroy all !"); - } - } - /// /// 获取模块 /// diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModuleDriver.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModuleDriver.cs index ce8fd36..c9d78a8 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModuleDriver.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniModule/Runtime/UniModuleDriver.cs @@ -8,10 +8,5 @@ namespace UniFramework.Module { UniModule.Update(); } - - void OnDestroy() - { - UniModule.Destroy(); - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPooling.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPooling.cs index eb749d6..4405b30 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPooling.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPooling.cs @@ -12,8 +12,8 @@ namespace UniFramework.Pooling public static class UniPooling { private static bool _isInitialize = false; + private static GameObject _driver = null; private static readonly List _spawners = new List(); - private static GameObject _poolingRoot; /// @@ -28,9 +28,30 @@ namespace UniFramework.Pooling { // 创建驱动器 _isInitialize = true; - _poolingRoot = new UnityEngine.GameObject($"[{nameof(UniPooling)}]"); - _poolingRoot.AddComponent(); - UnityEngine.Object.DontDestroyOnLoad(_poolingRoot); + _driver = new UnityEngine.GameObject($"[{nameof(UniPooling)}]"); + _driver.AddComponent(); + UnityEngine.Object.DontDestroyOnLoad(_driver); + UniLogger.Log($"{nameof(UniPooling)} initalize !"); + } + } + + /// + /// 销毁游戏对象池系统 + /// + public static void Destroy() + { + if (_isInitialize) + { + foreach (var spawner in _spawners) + { + spawner.Destroy(); + } + _spawners.Clear(); + + _isInitialize = false; + if (_driver != null) + GameObject.Destroy(_driver); + UniLogger.Log($"{nameof(UniPooling)} destroy all !"); } } @@ -48,25 +69,6 @@ namespace UniFramework.Pooling } } - /// - /// 销毁游戏对象池系统 - /// - internal static void Destroy() - { - if (_isInitialize) - { - foreach (var spawner in _spawners) - { - spawner.Destroy(); - } - - _spawners.Clear(); - _isInitialize = false; - UniLogger.Log($"{nameof(UniPooling)} destroy all !"); - } - } - - /// /// 创建游戏对象生成器 /// @@ -87,7 +89,7 @@ namespace UniFramework.Pooling if (HasSpawner(packageName)) return GetSpawner(packageName); - Spawner spawner = new Spawner(_poolingRoot, assetPackage); + Spawner spawner = new Spawner(_driver, assetPackage); _spawners.Add(spawner); return spawner; } diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPoolingDriver.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPoolingDriver.cs index 6e5dcd2..b928a02 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPoolingDriver.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniPooling/Runtime/UniPoolingDriver.cs @@ -8,10 +8,5 @@ namespace UniFramework.Pooling { UniPooling.Update(); } - - void OnDestroy() - { - UniPooling.Destroy(); - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindow.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindow.cs index f720a9f..4284e2e 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindow.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindow.cs @@ -17,6 +17,7 @@ namespace UniFramework.Window } private static bool _isInitialize = false; + private static GameObject _driver = null; private static readonly List _stack = new List(100); internal static GameObject Desktop { private set; get; } @@ -35,14 +36,31 @@ namespace UniFramework.Window { // 创建驱动器 _isInitialize = true; - GameObject driver = new UnityEngine.GameObject($"[{nameof(UniWindow)}]"); - driver.AddComponent(); - UnityEngine.Object.DontDestroyOnLoad(driver); + _driver = new UnityEngine.GameObject($"[{nameof(UniWindow)}]"); + _driver.AddComponent(); + UnityEngine.Object.DontDestroyOnLoad(_driver); + UniLogger.Log($"{nameof(UniWindow)} initalize !"); Desktop = desktop; } } + /// + /// 销毁界面系统 + /// + public static void Destroy() + { + if (_isInitialize) + { + CloseAll(); + + _isInitialize = false; + if (_driver != null) + GameObject.Destroy(_driver); + UniLogger.Log($"{nameof(UniWindow)} destroy all !"); + } + } + /// /// 更新界面系统 /// @@ -61,20 +79,6 @@ namespace UniFramework.Window } } - /// - /// 销毁界面系统 - /// - internal static void Destroy() - { - if (_isInitialize) - { - _isInitialize = false; - CloseAll(); - UniLogger.Log($"{nameof(UniWindow)} destroy all !"); - } - } - - /// /// 设置屏幕安全区域(异形屏支持) /// diff --git a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindowDriver.cs b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindowDriver.cs index 7060036..01858b6 100644 --- a/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindowDriver.cs +++ b/Assets/YooAsset/Samples~/Space Shooter/ThirdParty/UniFramework/UniWindow/Runtime/UniWindowDriver.cs @@ -8,10 +8,5 @@ namespace UniFramework.Window { UniWindow.Update(); } - - void OnDestroy() - { - UniWindow.Destroy(); - } } } \ No newline at end of file