From f615d8ddb03803a0bff58e3ef1f98febf366a3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=B3=95=E6=89=8B=E7=88=B1=E4=B8=BD?= =?UTF-8?q?=E4=B8=9D?= <1747715394@qq.com> Date: Wed, 12 Nov 2025 07:04:31 +0800 Subject: [PATCH] 111 --- Assets/GameFramework/Editor/BuildTool.cs | 149 +++---- Assets/GameFramework/Editor/CopyHotDll.cs | 98 ++--- Assets/GameFramework/Runtime/Asset.cs | 15 + Assets/GameFramework/Runtime/Asset.cs.meta | 2 + Assets/GameFramework/Runtime/Boot.cs | 55 +-- .../Runtime/EventSystem/EventBus.cs | 109 +++--- .../Runtime/EventSystem/IEvent.cs | 47 +-- .../Runtime/GameFramework.Runtime.asmdef | 3 +- Assets/GameFramework/Runtime/GameManager.cs | 5 +- Assets/GameFramework/Runtime/MainUICanvas.cs | 23 +- Assets/GameFramework/Runtime/MessageBox.cs | 133 +++---- .../Runtime/{PatchLogic.meta => Patch.meta} | 0 .../Runtime/Patch/HotDllLoader.cs | 46 +++ .../HotDllLoader.cs.meta | 0 .../Runtime/Patch/MainOperation.cs | 65 ++++ .../MainOperation.cs.meta | 0 .../GameFramework/Runtime/Patch/PatchEvent.cs | 31 ++ .../{PatchLogic => Patch}/PatchEvent.cs.meta | 0 .../Runtime/Patch/PatchManager.cs | 22 ++ .../PatchManager.cs.meta | 0 .../Runtime/Patch/PatchOperation.cs | 362 ++++++++++++++++++ .../PatchOperation.cs.meta | 0 .../Runtime/Patch/PreloadOperation.cs | 91 +++++ .../PreloadOperation.cs.meta | 0 .../Runtime/PatchLogic/HotDllLoader.cs | 43 --- .../Runtime/PatchLogic/MainOperation.cs | 62 --- .../Runtime/PatchLogic/PatchEvent.cs | 28 -- .../Runtime/PatchLogic/PatchManager.cs | 19 - .../Runtime/PatchLogic/PatchOperation.cs | 358 ----------------- .../Runtime/PatchLogic/PreloadOperation.cs | 88 ----- Assets/GameFramework/Runtime/Singleton.cs | 25 +- Assets/GameFramework/Runtime/SingletonMono.cs | 31 +- .../Main/InputActions.meta} | 2 +- .../InputActions/PlayerActions.inputactions | 79 ++++ .../PlayerActions.inputactions.meta | 14 + .../GameScripts/Main/GameScripts.Main.asmdef | 3 +- Assets/GameScripts/Main/GameStart.cs | 40 +- .../Main/Player/ThirdCharacterController.cs | 55 ++- Assets/GameScripts/Main/UI/SimpleR3Test.cs | 22 +- Assets/GameScripts/Main/UI/UIBase.cs | 63 +-- Assets/GameScripts/Main/UI/UIManager.cs | 260 ++++++------- Assets/GameScripts/Main/UI/UnityUIBindings.cs | 2 +- Assets/GameScripts/Preload/GamePreload.cs | 12 +- Assets/GameScripts/Preload/PatchWindow.cs | 78 ++-- .../AssetBundleCollectorConfig.xml | 3 + .../AssetBundleCollectorSetting.asset | 13 + .../InputSystem_Actions.inputactions | 1 + .../InputSystem_Actions.inputactions.meta | 0 .../UniTask/Runtime/External/YooAsset.meta | 2 +- .../YooAsset/AsyncOperationBaseExtensions.cs | 0 .../AsyncOperationBaseExtensions.cs.meta | 2 +- .../YooAsset/OperationHandleBaseExtensions.cs | 0 .../OperationHandleBaseExtensions.cs.meta | 2 +- .../External/YooAsset/UniTask.YooAsset.asmdef | 0 .../YooAsset/UniTask.YooAsset.asmdef.meta | 2 +- .../UniTask/Runtime/_InternalVisibleTo.cs | 3 +- .../2.3.17/UniTask Sample/README-IMG.png | Bin 48551 -> 0 bytes .../2.3.17/UniTask Sample/README-IMG.png.meta | 153 -------- .../YooAsset/2.3.17/UniTask Sample/README.md | 82 ---- .../2.3.17/UniTask Sample/README.md.meta | 7 - .../2.3.17/UniTask Sample/UniTask.meta | 8 - .../UniTask Sample/UniTask/Runtime.meta | 8 - .../UniTask/Runtime/External.meta | 8 - .../2.3.17/UniTask Sample/UniTaskRef.meta | 8 - .../UniTaskRef/UniTaskRef.asmref | 3 - .../UniTaskRef/UniTaskRef.asmref.meta | 7 - .../UniTaskRef/_InternalVisibleTo.cs | 3 - .../UniTaskRef/_InternalVisibleTo.cs.meta | 11 - 68 files changed, 1388 insertions(+), 1478 deletions(-) create mode 100644 Assets/GameFramework/Runtime/Asset.cs create mode 100644 Assets/GameFramework/Runtime/Asset.cs.meta rename Assets/GameFramework/Runtime/{PatchLogic.meta => Patch.meta} (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/HotDllLoader.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/HotDllLoader.cs.meta (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/MainOperation.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/MainOperation.cs.meta (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/PatchEvent.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/PatchEvent.cs.meta (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/PatchManager.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/PatchManager.cs.meta (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/PatchOperation.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/PatchOperation.cs.meta (100%) create mode 100644 Assets/GameFramework/Runtime/Patch/PreloadOperation.cs rename Assets/GameFramework/Runtime/{PatchLogic => Patch}/PreloadOperation.cs.meta (100%) delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/HotDllLoader.cs delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/MainOperation.cs delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/PatchEvent.cs delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/PatchManager.cs delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/PatchOperation.cs delete mode 100644 Assets/GameFramework/Runtime/PatchLogic/PreloadOperation.cs rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample.meta => GameRes/Main/InputActions.meta} (77%) create mode 100644 Assets/GameRes/Main/InputActions/PlayerActions.inputactions create mode 100644 Assets/GameRes/Main/InputActions/PlayerActions.inputactions.meta rename Assets/{GameRes/Main => GameSetting}/InputSystem_Actions.inputactions (99%) rename Assets/{GameRes/Main => GameSetting}/InputSystem_Actions.inputactions.meta (100%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset.meta (77%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs (100%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs.meta (53%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/OperationHandleBaseExtensions.cs (100%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/OperationHandleBaseExtensions.cs.meta (53%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/UniTask.YooAsset.asmdef (100%) rename Assets/{ThirdParty/YooAsset/2.3.17/UniTask Sample => Plugins}/UniTask/Runtime/External/YooAsset/UniTask.YooAsset.asmdef.meta (76%) delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/README-IMG.png delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/README-IMG.png.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/README.md delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/README.md.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTask.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTask/Runtime.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTask/Runtime/External.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTaskRef.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTaskRef/UniTaskRef.asmref delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTaskRef/UniTaskRef.asmref.meta delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTaskRef/_InternalVisibleTo.cs delete mode 100644 Assets/ThirdParty/YooAsset/2.3.17/UniTask Sample/UniTaskRef/_InternalVisibleTo.cs.meta diff --git a/Assets/GameFramework/Editor/BuildTool.cs b/Assets/GameFramework/Editor/BuildTool.cs index 0e7e876..01e1eb6 100644 --- a/Assets/GameFramework/Editor/BuildTool.cs +++ b/Assets/GameFramework/Editor/BuildTool.cs @@ -6,83 +6,84 @@ using System; using System.Collections.Generic; using UnityEditor.Build.Pipeline; -public class BuildTool +namespace Tuan.GameFramework { - [MenuItem("Tools/打包Preload")] - public static void BuildPreload() + public class BuildTool { - CopyHotDll.CopyPreloadDll2Byte(); - ExecuteBuild("Preload",EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget,EFileNameStyle.BundleName,EBuildinFileCopyOption.ClearAndCopyAll); - Debug.Log($"打包Preload结束"); - } - [MenuItem("Tools/打包Main %G")] - public static void BuildMain() - { - CopyHotDll.CopyMainDll2Byte(); - ExecuteBuild("Main", EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget, EFileNameStyle.BundleName, EBuildinFileCopyOption.None); - Debug.Log($"打包Main结束"); - } - [MenuItem("Tools/全部打包")] - public static void BuildAll() - { - BuildPreload(); - BuildMain(); - } + [MenuItem("Tools/打包Preload")] + public static void BuildPreload() + { + CopyHotDll.CopyPreloadDll2Byte(); + ExecuteBuild("Preload", EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget, EFileNameStyle.BundleName, EBuildinFileCopyOption.ClearAndCopyAll); + Debug.Log($"打包Preload结束"); + } + [MenuItem("Tools/打包Main %G")] + public static void BuildMain() + { + CopyHotDll.CopyMainDll2Byte(); + ExecuteBuild("Main", EBuildPipeline.ScriptableBuildPipeline, EditorUserBuildSettings.activeBuildTarget, EFileNameStyle.BundleName, EBuildinFileCopyOption.None); + Debug.Log($"打包Main结束"); + } + [MenuItem("Tools/全部打包")] + public static void BuildAll() + { + BuildPreload(); + BuildMain(); + } - public static void ExecuteBuild(string PackageName, EBuildPipeline BuildPipeline, BuildTarget BuildTarget, EFileNameStyle fileNameStyle, EBuildinFileCopyOption buildinFileCopyOption) - { - var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline.ToString()); - var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline.ToString()); - var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline.ToString()); - var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline.ToString()); - var builtinShaderBundleName = GetBuiltinShaderBundleName(PackageName); + public static void ExecuteBuild(string PackageName, EBuildPipeline BuildPipeline, BuildTarget BuildTarget, EFileNameStyle fileNameStyle, EBuildinFileCopyOption buildinFileCopyOption) + { + var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline.ToString()); + var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline.ToString()); + var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline.ToString()); + var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline.ToString()); + var builtinShaderBundleName = GetBuiltinShaderBundleName(PackageName); - ScriptableBuildParameters buildParameters = new ScriptableBuildParameters(); - buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); - buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); - buildParameters.BuildPipeline = BuildPipeline.ToString(); - buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle; - buildParameters.BuildTarget = BuildTarget; - buildParameters.PackageName = PackageName; - buildParameters.PackageVersion = GetPackageVersion(); - buildParameters.EnableSharePackRule = true; - buildParameters.VerifyBuildingResult = true; - buildParameters.FileNameStyle = fileNameStyle; - buildParameters.BuildinFileCopyOption = buildinFileCopyOption; - buildParameters.BuildinFileCopyParams = buildinFileCopyParams; - buildParameters.CompressOption = compressOption; - buildParameters.ClearBuildCacheFiles = clearBuildCache; - buildParameters.UseAssetDependencyDB = useAssetDependencyDB; - buildParameters.BuiltinShadersBundleName = builtinShaderBundleName; - buildParameters.EncryptionServices = CreateEncryptionInstance(PackageName, BuildPipeline); + ScriptableBuildParameters buildParameters = new ScriptableBuildParameters(); + buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); + buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); + buildParameters.BuildPipeline = BuildPipeline.ToString(); + buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle; + buildParameters.BuildTarget = BuildTarget; + buildParameters.PackageName = PackageName; + buildParameters.PackageVersion = GetPackageVersion(); + buildParameters.EnableSharePackRule = true; + buildParameters.VerifyBuildingResult = true; + buildParameters.FileNameStyle = fileNameStyle; + buildParameters.BuildinFileCopyOption = buildinFileCopyOption; + buildParameters.BuildinFileCopyParams = buildinFileCopyParams; + buildParameters.CompressOption = compressOption; + buildParameters.ClearBuildCacheFiles = clearBuildCache; + buildParameters.UseAssetDependencyDB = useAssetDependencyDB; + buildParameters.BuiltinShadersBundleName = builtinShaderBundleName; + buildParameters.EncryptionServices = CreateEncryptionInstance(PackageName, BuildPipeline); - ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline(); - var buildResult = pipeline.Run(buildParameters, true); - if (buildResult.Success) - EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline(); + var buildResult = pipeline.Run(buildParameters, true); + if (buildResult.Success) + EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory); + } + public static string GetPackageVersion() + { + int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute; + return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes; + } + + private static string GetBuiltinShaderBundleName(string PackageName) + { + var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName; + var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); + return packRuleResult.GetBundleName(PackageName, uniqueBundleName); + } + public static IEncryptionServices CreateEncryptionInstance(string PackageName, EBuildPipeline BuildPipeline) + { + var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, BuildPipeline.ToString()); + var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); + var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName)); + if (classType != null) + return (IEncryptionServices)Activator.CreateInstance(classType); + else + return null; + } } - public static string GetPackageVersion() - { - int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute; - return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes; - } - - private static string GetBuiltinShaderBundleName(string PackageName) - { - var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName; - var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); - return packRuleResult.GetBundleName(PackageName, uniqueBundleName); - } - public static IEncryptionServices CreateEncryptionInstance(string PackageName, EBuildPipeline BuildPipeline) - { - var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, BuildPipeline.ToString()); - var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); - var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName)); - if (classType != null) - return (IEncryptionServices)Activator.CreateInstance(classType); - else - return null; - } -} - - +} \ No newline at end of file diff --git a/Assets/GameFramework/Editor/CopyHotDll.cs b/Assets/GameFramework/Editor/CopyHotDll.cs index ab527eb..98b39dd 100644 --- a/Assets/GameFramework/Editor/CopyHotDll.cs +++ b/Assets/GameFramework/Editor/CopyHotDll.cs @@ -2,58 +2,60 @@ using UnityEditor; using UnityEngine; using System.IO; - -public class CopyHotDll +namespace Tuan.GameFramework { - [MenuItem("Tools/更新生成PreloadDll")] - public static void CopyPreloadDll2Byte() + public class CopyHotDll { - HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); - string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/HotUpdateDlls/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/GameScripts.Preload.dll"; - string destDir = $"{Application.dataPath}/GameRes/Preload/HotUpdateDll/GameScripts.Preload.bytes"; - if (File.Exists(destDir)) + [MenuItem("Tools/更新生成PreloadDll")] + public static void CopyPreloadDll2Byte() { - File.Delete(destDir); - } - File.Copy(sourceDir, destDir); - AssetDatabase.Refresh(); - Debug.Log($"copy {sourceDir} to {destDir}"); - } - [MenuItem("Tools/更新生成MainDll")] - public static void CopyMainDll2Byte() - { - HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); - string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/HotUpdateDlls/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/GameScripts.Main.dll"; - string destDir = $"{Application.dataPath}/GameRes/Main/HotUpdateDll/GameScripts.Main.bytes"; - if (File.Exists(destDir)) - { - File.Delete(destDir); - } - File.Copy(sourceDir, destDir); - AssetDatabase.Refresh(); - Debug.Log($"copy {sourceDir} to {destDir}"); - } - [MenuItem("Tools/更新生成补充数据源")] - public static void CopyDepDll2Byte() - { - HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); - string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/AssembliesPostIl2CppStrip/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/"; - string destDir = $"{Application.dataPath}/GameRes/Main/HotUpdateDll/"; - foreach (string dll in HotDllLoader.Inst.DepDlls) - { - string sourcePath = $"{sourceDir}/{dll}"; - string destPath = $"{destDir}/{dll}.bytes"; - if (File.Exists(sourcePath)) + HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); + string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/HotUpdateDlls/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/GameScripts.Preload.dll"; + string destDir = $"{Application.dataPath}/GameRes/Preload/HotUpdateDll/GameScripts.Preload.bytes"; + if (File.Exists(destDir)) { - if (File.Exists(destPath)) - { - File.Delete(destPath); - } - File.Copy(sourcePath, destPath); - AssetDatabase.Refresh(); - Debug.Log($"copy {sourcePath} to {destPath}"); + File.Delete(destDir); } + File.Copy(sourceDir, destDir); + AssetDatabase.Refresh(); + Debug.Log($"copy {sourceDir} to {destDir}"); + } + [MenuItem("Tools/更新生成MainDll")] + public static void CopyMainDll2Byte() + { + HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); + string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/HotUpdateDlls/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/GameScripts.Main.dll"; + string destDir = $"{Application.dataPath}/GameRes/Main/HotUpdateDll/GameScripts.Main.bytes"; + if (File.Exists(destDir)) + { + File.Delete(destDir); + } + File.Copy(sourceDir, destDir); + AssetDatabase.Refresh(); + Debug.Log($"copy {sourceDir} to {destDir}"); + } + [MenuItem("Tools/更新生成补充数据源")] + public static void CopyDepDll2Byte() + { + HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget(); + string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/AssembliesPostIl2CppStrip/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/"; + string destDir = $"{Application.dataPath}/GameRes/Main/HotUpdateDll/"; + foreach (string dll in HotDllLoader.Inst.DepDlls) + { + string sourcePath = $"{sourceDir}/{dll}"; + string destPath = $"{destDir}/{dll}.bytes"; + if (File.Exists(sourcePath)) + { + if (File.Exists(destPath)) + { + File.Delete(destPath); + } + File.Copy(sourcePath, destPath); + AssetDatabase.Refresh(); + Debug.Log($"copy {sourcePath} to {destPath}"); + } + } + Debug.Log("copy over"); } - Debug.Log("copy over"); } -} +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/Asset.cs b/Assets/GameFramework/Runtime/Asset.cs new file mode 100644 index 0000000..ce5594c --- /dev/null +++ b/Assets/GameFramework/Runtime/Asset.cs @@ -0,0 +1,15 @@ +using Cysharp.Threading.Tasks; +using UnityEngine; +using YooAsset; + +namespace Tuan.GameFramework +{ + public class Asset : MonoBehaviour + { + async UniTask LoadAsync(string name) + { + AssetHandle handle = YooAssets.LoadAssetAsync(name); + await handle.ToUniTask(); + } + } +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/Asset.cs.meta b/Assets/GameFramework/Runtime/Asset.cs.meta new file mode 100644 index 0000000..4cb98ed --- /dev/null +++ b/Assets/GameFramework/Runtime/Asset.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d9170e9f660395d47b0f02466e5fd091 \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/Boot.cs b/Assets/GameFramework/Runtime/Boot.cs index 7a59c6b..801ae4f 100644 --- a/Assets/GameFramework/Runtime/Boot.cs +++ b/Assets/GameFramework/Runtime/Boot.cs @@ -2,34 +2,37 @@ using Cysharp.Threading.Tasks; using UnityEngine; using YooAsset; -public class Boot : MonoBehaviour +namespace Tuan.GameFramework { - public Camera MainCamera; - public EPlayMode PlayMode = EPlayMode.EditorSimulateMode; - void Awake() + public class Boot : MonoBehaviour { -#if UNITY_EDITOR - //PlayerPrefs.DeleteAll(); -#endif - Application.targetFrameRate = 60; - Application.runInBackground = true; - DontDestroyOnLoad(MainCamera); - } - async void Start() - { - bool updateSuccess = await PatchManager.Inst.StartOperation(PlayMode); - if (updateSuccess) - await EnterGame(); - } - private async UniTask EnterGame() - { - Debug.Log("EnterGame"); - var assetHandle = YooAssets.TryGetPackage("Main").LoadSceneAsync("Test"); - await assetHandle.ToUniTask(); - if (assetHandle.Status == EOperationStatus.Succeed) + public Camera MainCamera; + public EPlayMode PlayMode = EPlayMode.EditorSimulateMode; + void Awake() { - assetHandle.ActivateScene(); - PatchEvent.ClosePatchWindow(); +#if UNITY_EDITOR + //PlayerPrefs.DeleteAll(); +#endif + Application.targetFrameRate = 60; + Application.runInBackground = true; + DontDestroyOnLoad(MainCamera); + } + async void Start() + { + bool updateSuccess = await PatchManager.Inst.StartOperation(PlayMode); + if (updateSuccess) + await EnterGame(); + } + private async UniTask EnterGame() + { + Debug.Log("EnterGame"); + var assetHandle = YooAssets.TryGetPackage("Main").LoadSceneAsync("Test"); + await assetHandle.ToUniTask(); + if (assetHandle.Status == EOperationStatus.Succeed) + { + assetHandle.ActivateScene(); + PatchEvent.ClosePatchWindow(); + } } } -} +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/EventSystem/EventBus.cs b/Assets/GameFramework/Runtime/EventSystem/EventBus.cs index 22ba67d..eb7a161 100644 --- a/Assets/GameFramework/Runtime/EventSystem/EventBus.cs +++ b/Assets/GameFramework/Runtime/EventSystem/EventBus.cs @@ -2,87 +2,90 @@ using System.Collections.Generic; using System; using UnityEngine; -public static class EventBus +namespace Tuan.GameFramework { - - private static readonly Dictionary _eventHandlers = new Dictionary(); - private static readonly object _lock = new object(); - - public static void Register(IEventHandler handler) where TEvent : IEvent + public static class EventBus { - lock (_lock) - { - Type eventType = typeof(TEvent); - if (!_eventHandlers.ContainsKey(eventType)) - { - _eventHandlers[eventType] = new List>(); - } - var handlers = _eventHandlers[eventType] as List>; - if (handler != null && !handlers.Contains(handler)) - { - handlers.Add(handler); - } - } - } + private static readonly Dictionary _eventHandlers = new Dictionary(); + private static readonly object _lock = new object(); - public static void Unregister(IEventHandler handler) where TEvent : IEvent - { - lock (_lock) + public static void Register(IEventHandler handler) where TEvent : IEvent { - Type eventType = typeof(TEvent); - if (_eventHandlers.ContainsKey(eventType)) + lock (_lock) { + Type eventType = typeof(TEvent); + if (!_eventHandlers.ContainsKey(eventType)) + { + _eventHandlers[eventType] = new List>(); + } + var handlers = _eventHandlers[eventType] as List>; - handlers?.Remove(handler); - - if (handlers != null && handlers.Count == 0) + if (handler != null && !handlers.Contains(handler)) { - _eventHandlers.Remove(eventType); + handlers.Add(handler); } } } - } - public static void Publish(TEvent eventData) where TEvent : IEvent - { - List> handlersToInvoke = null; - - lock (_lock) + public static void Unregister(IEventHandler handler) where TEvent : IEvent { - Type eventType = typeof(TEvent); - if (_eventHandlers.ContainsKey(eventType)) + lock (_lock) { - var handlers = _eventHandlers[eventType] as List>; - if (handlers != null && handlers.Count > 0) + Type eventType = typeof(TEvent); + if (_eventHandlers.ContainsKey(eventType)) { - handlersToInvoke = new List>(handlers); + var handlers = _eventHandlers[eventType] as List>; + handlers?.Remove(handler); + + if (handlers != null && handlers.Count == 0) + { + _eventHandlers.Remove(eventType); + } } } } - // 在锁外执行事件处理,避免死锁 - if (handlersToInvoke != null) + public static void Publish(TEvent eventData) where TEvent : IEvent { - foreach (var handler in handlersToInvoke) + List> handlersToInvoke = null; + + lock (_lock) { - try + Type eventType = typeof(TEvent); + if (_eventHandlers.ContainsKey(eventType)) { - handler?.HandleEvent(eventData); + var handlers = _eventHandlers[eventType] as List>; + if (handlers != null && handlers.Count > 0) + { + handlersToInvoke = new List>(handlers); + } } - catch (Exception e) + } + + // 在锁外执行事件处理,避免死锁 + if (handlersToInvoke != null) + { + foreach (var handler in handlersToInvoke) { - Debug.LogError($"Event handling error in {handler.GetType().Name}: {e}"); + try + { + handler?.HandleEvent(eventData); + } + catch (Exception e) + { + Debug.LogError($"Event handling error in {handler.GetType().Name}: {e}"); + } } } } - } - public static void Clear() - { - lock (_lock) + public static void Clear() { - _eventHandlers.Clear(); + lock (_lock) + { + _eventHandlers.Clear(); + } } } -} +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/EventSystem/IEvent.cs b/Assets/GameFramework/Runtime/EventSystem/IEvent.cs index 1afd3e6..bfc2e20 100644 --- a/Assets/GameFramework/Runtime/EventSystem/IEvent.cs +++ b/Assets/GameFramework/Runtime/EventSystem/IEvent.cs @@ -1,27 +1,30 @@ -public interface IEvent { } - -public interface IEventHandler where TEvent : IEvent +namespace Tuan.GameFramework { - void HandleEvent(TEvent eventData); -} + public interface IEvent { } -public struct ApplicationFocusEvent : IEvent -{ - public bool HasFocus; -} - -public struct SceneLoadEvent : IEvent -{ - public string SceneName; - public float Progress; -} - -public abstract class EventHandler : IEventHandler where TEvent : IEvent -{ - public void HandleEvent(TEvent eventData) + public interface IEventHandler where TEvent : IEvent { - OnEvent(eventData); + void HandleEvent(TEvent eventData); } - protected abstract void OnEvent(TEvent eventData); -} + public struct ApplicationFocusEvent : IEvent + { + public bool HasFocus; + } + + public struct SceneLoadEvent : IEvent + { + public string SceneName; + public float Progress; + } + + public abstract class EventHandler : IEventHandler where TEvent : IEvent + { + public void HandleEvent(TEvent eventData) + { + OnEvent(eventData); + } + + protected abstract void OnEvent(TEvent eventData); + } +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/GameFramework.Runtime.asmdef b/Assets/GameFramework/Runtime/GameFramework.Runtime.asmdef index 01a6226..73f1e82 100644 --- a/Assets/GameFramework/Runtime/GameFramework.Runtime.asmdef +++ b/Assets/GameFramework/Runtime/GameFramework.Runtime.asmdef @@ -5,7 +5,8 @@ "GUID:e34a5702dd353724aa315fb8011f08c3", "GUID:f51ebe6a0ceec4240a699833d6309b23", "GUID:3fe1a3e70da50184f9897101cad7e4f2", - "GUID:13ba8ce62aa80c74598530029cb2d649" + "GUID:13ba8ce62aa80c74598530029cb2d649", + "GUID:928f8a513cd12e84cb0d3c0a21a84e2f" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/GameFramework/Runtime/GameManager.cs b/Assets/GameFramework/Runtime/GameManager.cs index 6afddfb..2b38a75 100644 --- a/Assets/GameFramework/Runtime/GameManager.cs +++ b/Assets/GameFramework/Runtime/GameManager.cs @@ -1,6 +1,9 @@ using UnityEngine; -public class GameManager : Singleton +namespace Tuan.GameFramework { + public class GameManager : Singleton + { + } } diff --git a/Assets/GameFramework/Runtime/MainUICanvas.cs b/Assets/GameFramework/Runtime/MainUICanvas.cs index cdf493b..4369a29 100644 --- a/Assets/GameFramework/Runtime/MainUICanvas.cs +++ b/Assets/GameFramework/Runtime/MainUICanvas.cs @@ -1,15 +1,18 @@ using UnityEngine; -public class MainUICanvas : SingletonMono +namespace Tuan.GameFramework { - public GameObject InitBg; - public RectTransform Top; - public RectTransform Medium; - public RectTransform Bottom; - public Camera UICamera; - private void Awake() + public class MainUICanvas : SingletonMono { - DontDestroyOnLoad(gameObject); - DontDestroyOnLoad(UICamera); + public GameObject InitBg; + public RectTransform Top; + public RectTransform Medium; + public RectTransform Bottom; + public Camera UICamera; + private void Awake() + { + DontDestroyOnLoad(gameObject); + DontDestroyOnLoad(UICamera); + } } -} +} \ No newline at end of file diff --git a/Assets/GameFramework/Runtime/MessageBox.cs b/Assets/GameFramework/Runtime/MessageBox.cs index 88c00f9..ea6a117 100644 --- a/Assets/GameFramework/Runtime/MessageBox.cs +++ b/Assets/GameFramework/Runtime/MessageBox.cs @@ -3,84 +3,87 @@ using UnityEngine.UI; using System; using System.Collections.Generic; -public class MessageBox : MonoBehaviour +namespace Tuan.GameFramework { - [SerializeField] private GameObject panel; - [SerializeField] private Text titleText; - [SerializeField] private Text contentText; - [SerializeField] private Transform buttonsParent; - [SerializeField] private GameObject buttonPrefab; - - private static readonly List hiddenMessageBoxes = new List(); - private readonly List