diff --git a/Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowserWindow.cs b/Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowserWindow.cs index 7c1fed9..13d11f1 100644 --- a/Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowserWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowserWindow.cs @@ -1,8 +1,11 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; +using UnityEditor.UIElements; -public class AssetBundleBrowserWindow +namespace YooAsset.Editor { + public class AssetBundleBrowserWindow + { + } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index 611d48b..0b4618d 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs index 98900c4..c06e862 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEditor; -using YooAsset.Utility; namespace YooAsset.Editor { @@ -125,7 +124,7 @@ namespace YooAsset.Editor /// /// 从输出目录加载补丁清单文件 /// - public static PatchManifest LoadPatchManifestFile(string fileDirectory) + internal static PatchManifest LoadPatchManifestFile(string fileDirectory) { string filePath = $"{fileDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}"; if (File.Exists(filePath) == false) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs index 18a0bbd..a393d35 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs @@ -2,7 +2,6 @@ using System.IO; using System.Collections; using System.Collections.Generic; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs index 7085c57..d40dc1e 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs @@ -3,7 +3,6 @@ using System.Linq; using System.IO; using System.Collections; using System.Collections.Generic; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs index fd3163b..d411dec 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Collections; using System.Collections.Generic; using UnityEditor; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs index f55d2dc..547e87b 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index cc4b03a..366fbcd 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEditor; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectorConfigImporter.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectorConfigImporter.cs index b26cd66..8c50764 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectorConfigImporter.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectorConfigImporter.cs @@ -4,7 +4,6 @@ using System.Xml; using System.Collections.Generic; using UnityEditor; using UnityEngine; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs index 9823a8a..28c1cbb 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs @@ -1,7 +1,6 @@ using System; using System.IO; using UnityEditor; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Runtime/Logger.meta b/Assets/YooAsset/Editor/AssetBundleProfiler.meta similarity index 77% rename from Assets/YooAsset/Runtime/Logger.meta rename to Assets/YooAsset/Editor/AssetBundleProfiler.meta index 92cf8b9..fd2db89 100644 --- a/Assets/YooAsset/Runtime/Logger.meta +++ b/Assets/YooAsset/Editor/AssetBundleProfiler.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f3763af65a2f76945bd4a6adc720ec07 +guid: 5b503bf79c4303d4794d7c9414a4c201 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs b/Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs new file mode 100644 index 0000000..248adc1 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace YooAsset.Editor +{ + public class AssetBundleProfilerWindow + { + + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/StringUtility.cs.meta b/Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs.meta similarity index 83% rename from Assets/YooAsset/Runtime/Utility/StringUtility.cs.meta rename to Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs.meta index 78b6e49..2a315f3 100644 --- a/Assets/YooAsset/Runtime/Utility/StringUtility.cs.meta +++ b/Assets/YooAsset/Editor/AssetBundleProfiler/AssetBundleProfilerWindow.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8ce33ab90add0ab4aa7063977e23284e +guid: 7375e313be9e6b24ab7193e64a67fa07 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs index 1be6273..3399aa3 100644 --- a/Assets/YooAsset/Editor/EditorTools.cs +++ b/Assets/YooAsset/Editor/EditorTools.cs @@ -8,7 +8,6 @@ using System.Text.RegularExpressions; using UnityEngine; using UnityEditor; using UnityEditor.Animations; -using YooAsset.Utility; namespace YooAsset.Editor { diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetPathHelper.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetPathHelper.cs index f967c93..8da5de1 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetPathHelper.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetPathHelper.cs @@ -1,5 +1,4 @@ using System.IO; -using YooAsset.Utility; namespace YooAsset { @@ -113,7 +112,7 @@ namespace YooAsset } // 没有找到同名的资源文件 - Logger.Warning($"Not found asset : {filePath}"); + YooLogger.Warning($"Not found asset : {filePath}"); return filePath; #else throw new System.NotImplementedException(); diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index f078135..8be7f14 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -307,7 +307,7 @@ namespace YooAsset DebugSummy.DebugProviderInfo providerInfo = new DebugSummy.DebugProviderInfo(); providerInfo.AssetPath = provider.AssetPath; providerInfo.RefCount = provider.RefCount; - providerInfo.States = provider.States; + providerInfo.States = (int)provider.States; providerInfo.BundleInfos.Clear(); summy.ProviderInfos.Add(providerInfo); diff --git a/Assets/YooAsset/Runtime/AssetSystem/IBundleServices.cs b/Assets/YooAsset/Runtime/AssetSystem/IBundleServices.cs index ed1e26f..4d5717c 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/IBundleServices.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/IBundleServices.cs @@ -1,8 +1,8 @@  namespace YooAsset { - public interface IBundleServices - { + internal interface IBundleServices + { /// /// 获取AssetBundle的信息 /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Instance/SceneInstance.cs b/Assets/YooAsset/Runtime/AssetSystem/Instance/SceneInstance.cs index 7d908bf..92c08f8 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Instance/SceneInstance.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Instance/SceneInstance.cs @@ -34,7 +34,7 @@ namespace YooAsset } else { - Logger.Warning($"Scene is invalid or not loaded : {Scene.name}"); + YooLogger.Warning($"Scene is invalid or not loaded : {Scene.name}"); return false; } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/BundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/BundleFileLoader.cs index c7cb2bc..d5299b7 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/BundleFileLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/BundleFileLoader.cs @@ -136,7 +136,7 @@ namespace YooAsset // 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。 if (System.IO.File.Exists(BundleFileInfo.LocalPath) == false) { - Logger.Warning($"Not found assetBundle file : {BundleFileInfo.LocalPath}"); + YooLogger.Warning($"Not found assetBundle file : {BundleFileInfo.LocalPath}"); States = ELoaderStates.Fail; return; } @@ -188,7 +188,7 @@ namespace YooAsset if (_isWaitForAsyncComplete) { // 强制挂起主线程(注意:该操作会很耗时) - Logger.Warning("Suspend the main thread to load unity bundle."); + YooLogger.Warning("Suspend the main thread to load unity bundle."); CacheBundle = _cacheRequest.assetBundle; } else @@ -202,7 +202,7 @@ namespace YooAsset // Check error if (CacheBundle == null) { - Logger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}"); + YooLogger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}"); States = ELoaderStates.Fail; } else @@ -302,7 +302,7 @@ namespace YooAsset if (_isShowWaitForAsyncError == false) { _isShowWaitForAsyncError = true; - Logger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {States}"); + YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {States}"); } break; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/DependBundleGrouper.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/DependBundleGrouper.cs index 3d1d1c8..9176d05 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/DependBundleGrouper.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/DependBundleGrouper.cs @@ -74,7 +74,7 @@ namespace YooAsset debugInfo.BundleName = loader.BundleFileInfo.BundleName; debugInfo.Version = loader.BundleFileInfo.Version; debugInfo.RefCount = loader.RefCount; - debugInfo.States = loader.States; + debugInfo.States = (int)loader.States; output.Add(debugInfo); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/AssetProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/AssetProviderBase.cs index 6ee0582..96d1d16 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/AssetProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/AssetProviderBase.cs @@ -61,7 +61,7 @@ namespace YooAsset public void Release() { if (RefCount <= 0) - Logger.Warning("Asset provider reference count is already zero. There may be resource leaks !"); + YooLogger.Warning("Asset provider reference count is already zero. There may be resource leaks !"); RefCount--; } @@ -97,7 +97,7 @@ namespace YooAsset // 验证结果 if (IsDone == false) { - Logger.Warning($"WaitForAsyncComplete failed to loading : {AssetPath}"); + YooLogger.Warning($"WaitForAsyncComplete failed to loading : {AssetPath}"); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs index c0c2159..9dddcb3 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs @@ -84,7 +84,7 @@ namespace YooAsset if (IsWaitForAsyncComplete) { // 强制挂起主线程(注意:该操作会很耗时) - Logger.Warning("Suspend the main thread to load unity asset."); + YooLogger.Warning("Suspend the main thread to load unity asset."); AssetObject = _cacheRequest.asset; } else @@ -97,7 +97,7 @@ namespace YooAsset States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success; if (States == EAssetStates.Fail) - Logger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"); + YooLogger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"); InvokeCompletion(); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs index 31137ae..1a26259 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs @@ -42,7 +42,7 @@ namespace YooAsset ownerInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName; ownerInfo.Version = OwnerBundle.BundleFileInfo.Version; ownerInfo.RefCount = OwnerBundle.RefCount; - ownerInfo.States = OwnerBundle.States; + ownerInfo.States = (int)OwnerBundle.States; output.Add(ownerInfo); DependBundles.GetBundleDebugInfos(output); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs index 0908aa4..69afe9c 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs @@ -64,7 +64,7 @@ namespace YooAsset } else { - Logger.Warning($"Failed to load scene : {AssetName}"); + YooLogger.Warning($"Failed to load scene : {AssetName}"); States = EAssetStates.Fail; InvokeCompletion(); } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs index e36ef59..0114db5 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs @@ -84,7 +84,7 @@ namespace YooAsset if (IsWaitForAsyncComplete) { // 强制挂起主线程(注意:该操作会很耗时) - Logger.Warning("Suspend the main thread to load unity asset."); + YooLogger.Warning("Suspend the main thread to load unity asset."); AllAssets = _cacheRequest.allAssets; } else @@ -97,7 +97,7 @@ namespace YooAsset States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success; if (States == EAssetStates.Fail) - Logger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"); + YooLogger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"); InvokeCompletion(); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs index 966ad20..9b2f1ab 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs @@ -59,7 +59,7 @@ namespace YooAsset { States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success; if (States == EAssetStates.Fail) - Logger.Warning($"Failed to load asset object : {AssetPath}"); + YooLogger.Warning($"Failed to load asset object : {AssetPath}"); InvokeCompletion(); } #endif diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs index 375d263..d52fb8d 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs @@ -46,7 +46,7 @@ namespace YooAsset } else { - Logger.Warning($"Failed to load scene : {AssetName}"); + YooLogger.Warning($"Failed to load scene : {AssetName}"); States = EAssetStates.Fail; InvokeCompletion(); } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs index 118264d..9fa14e4 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs @@ -66,7 +66,7 @@ namespace YooAsset { States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success; if (States == EAssetStates.Fail) - Logger.Warning($"Failed to load all asset object : {AssetPath}"); + YooLogger.Warning($"Failed to load all asset object : {AssetPath}"); InvokeCompletion(); } #endif diff --git a/Assets/YooAsset/Runtime/Operation.meta b/Assets/YooAsset/Runtime/OperationSystem.meta similarity index 100% rename from Assets/YooAsset/Runtime/Operation.meta rename to Assets/YooAsset/Runtime/OperationSystem.meta diff --git a/Assets/YooAsset/Runtime/Operation/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs similarity index 100% rename from Assets/YooAsset/Runtime/Operation/AsyncOperationBase.cs rename to Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs diff --git a/Assets/YooAsset/Runtime/Operation/AsyncOperationBase.cs.meta b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Operation/AsyncOperationBase.cs.meta rename to Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs.meta diff --git a/Assets/YooAsset/Runtime/Operation/EOperationStatus.cs b/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs similarity index 100% rename from Assets/YooAsset/Runtime/Operation/EOperationStatus.cs rename to Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs diff --git a/Assets/YooAsset/Runtime/Operation/EOperationStatus.cs.meta b/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Operation/EOperationStatus.cs.meta rename to Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs.meta diff --git a/Assets/YooAsset/Runtime/Operation/OperationUpdater.cs b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs similarity index 94% rename from Assets/YooAsset/Runtime/Operation/OperationUpdater.cs rename to Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs index e15a79e..5682539 100644 --- a/Assets/YooAsset/Runtime/Operation/OperationUpdater.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace YooAsset { - internal class OperationUpdater + internal class OperationSystem { private static readonly List _operations = new List(100); diff --git a/Assets/YooAsset/Runtime/Operation/OperationUpdater.cs.meta b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Operation/OperationUpdater.cs.meta rename to Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs.meta diff --git a/Assets/YooAsset/Runtime/PatchSystem/Download/DownloadSystem.cs b/Assets/YooAsset/Runtime/PatchSystem/Download/DownloadSystem.cs index 867b07b..eff94e6 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Download/DownloadSystem.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Download/DownloadSystem.cs @@ -2,7 +2,6 @@ using System.IO; using System.Collections; using System.Collections.Generic; -using YooAsset.Utility; namespace YooAsset { @@ -62,7 +61,7 @@ namespace YooAsset // 创建新的下载器 { - Logger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}"); + YooLogger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}"); FileUtility.CreateFileDirectory(bundleInfo.LocalPath); var newDownloader = new FileDownloader(bundleInfo); newDownloader.SendRequest(failedTryAgain, timeout); @@ -96,7 +95,7 @@ namespace YooAsset { string bundleName = _cachedHashList[hash]; _cachedHashList.Remove(hash); - Logger.Error($"Cache file is missing : {bundleName} Hash : {hash}"); + YooLogger.Error($"Cache file is missing : {bundleName} Hash : {hash}"); return false; } } @@ -113,7 +112,7 @@ namespace YooAsset { if (_cachedHashList.ContainsKey(hash) == false) { - Logger.Log($"Cache verify file : {bundleName} Hash : {hash}"); + YooLogger.Log($"Cache verify file : {bundleName} Hash : {hash}"); _cachedHashList.Add(hash, bundleName); } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Download/FileDownloader.cs b/Assets/YooAsset/Runtime/PatchSystem/Download/FileDownloader.cs index 885a92e..40a8e13 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Download/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Download/FileDownloader.cs @@ -159,7 +159,7 @@ namespace YooAsset { _failedTryAgain--; _steps = ESteps.CreateDownload; - Logger.Warning($"Try again download : {_requestURL}"); + YooLogger.Warning($"Try again download : {_requestURL}"); } } } @@ -190,7 +190,7 @@ namespace YooAsset float offset = Time.realtimeSinceStartup - _latestDownloadRealtime; if (offset > _timeout) { - Logger.Warning($"Web file request timeout : {_requestURL}"); + YooLogger.Warning($"Web file request timeout : {_requestURL}"); _webRequest.Abort(); _isAbort = true; } @@ -236,7 +236,7 @@ namespace YooAsset /// public void ReportError() { - Logger.Error($"Failed to download : {_requestURL} Error : {_lastError}"); + YooLogger.Error($"Failed to download : {_requestURL} Error : {_lastError}"); } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/PatchSystem/Download/HttpDownloader.cs b/Assets/YooAsset/Runtime/PatchSystem/Download/HttpDownloader.cs index 569a3df..a482dd2 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Download/HttpDownloader.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Download/HttpDownloader.cs @@ -158,7 +158,7 @@ namespace YooAsset /// public void ReportError() { - Logger.Error(_downloadError); + YooLogger.Error(_downloadError); } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs index c3b9831..7552982 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs @@ -81,7 +81,7 @@ namespace YooAsset } internal override void Start() { - Logger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes"); + YooLogger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes"); _steps = ESteps.Loading; } internal override void Update() @@ -174,7 +174,7 @@ namespace YooAsset { if (_steps == ESteps.None) { - OperationUpdater.ProcessOperaiton(this); + OperationSystem.ProcessOperaiton(this); } } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs index ae4cd43..f3a0def 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs @@ -128,12 +128,12 @@ namespace YooAsset PatchCache cache = PatchCache.LoadCache(); if (cache.CacheAppVersion != Application.version) { - Logger.Warning($"Cache is dirty ! Cache app version is {cache.CacheAppVersion}, Current app version is {Application.version}"); + YooLogger.Warning($"Cache is dirty ! Cache app version is {cache.CacheAppVersion}, Current app version is {Application.version}"); // 注意:在覆盖安装的时候,会保留APP沙盒目录,可以选择清空缓存目录 if (_impl.ClearCacheWhenDirty) { - Logger.Warning("Clear cache files."); + YooLogger.Warning("Clear cache files."); PatchHelper.DeleteSandboxCacheFolder(); } @@ -148,7 +148,7 @@ namespace YooAsset if (_steps == ESteps.LoadAppManifest) { // 加载APP内的补丁清单 - Logger.Log($"Load application patch manifest."); + YooLogger.Log($"Load application patch manifest."); string filePath = AssetPathHelper.MakeStreamingLoadPath(ResourceSettingData.Setting.PatchManifestFileName); _downloadURL = AssetPathHelper.ConvertToWWWPath(filePath); _downloader = new UnityWebRequester(); @@ -183,7 +183,7 @@ namespace YooAsset // 加载沙盒内的补丁清单 if (PatchHelper.CheckSandboxPatchManifestFileExist()) { - Logger.Log($"Load sandbox patch manifest."); + YooLogger.Log($"Load sandbox patch manifest."); string filePath = AssetPathHelper.MakePersistentLoadPath(ResourceSettingData.Setting.PatchManifestFileName); string jsonData = File.ReadAllText(filePath); _impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData); diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs index 720ff12..c8469a7 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs @@ -81,11 +81,11 @@ namespace YooAsset if (_impl.IgnoreResourceVersion && _updateResourceVersion > 0) { - Logger.Warning($"Update resource version {_updateResourceVersion} is invalid when ignore resource version."); + YooLogger.Warning($"Update resource version {_updateResourceVersion} is invalid when ignore resource version."); } else { - Logger.Log($"Update patch manifest : update resource version is {_updateResourceVersion}"); + YooLogger.Log($"Update patch manifest : update resource version is {_updateResourceVersion}"); } } internal override void Update() @@ -96,7 +96,7 @@ namespace YooAsset if (_steps == ESteps.LoadWebManifestHash) { string webURL = GetPatchManifestRequestURL(_updateResourceVersion, ResourceSettingData.Setting.PatchManifestHashFileName); - Logger.Log($"Beginning to request patch manifest hash : {webURL}"); + YooLogger.Log($"Beginning to request patch manifest hash : {webURL}"); _downloaderHash = new UnityWebRequester(); _downloaderHash.SendRequest(webURL, _timeout); _steps = ESteps.CheckWebManifestHash; @@ -125,12 +125,12 @@ namespace YooAsset string currentFileHash = PatchHelper.GetSandboxPatchManifestFileHash(); if (currentFileHash == webManifestHash) { - Logger.Log($"Patch manifest file hash is not change : {webManifestHash}"); + YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}"); _steps = ESteps.InitPrepareCache; } else { - Logger.Log($"Patch manifest hash is change : {webManifestHash} -> {currentFileHash}"); + YooLogger.Log($"Patch manifest hash is change : {webManifestHash} -> {currentFileHash}"); _steps = ESteps.LoadWebManifest; } } @@ -138,7 +138,7 @@ namespace YooAsset if (_steps == ESteps.LoadWebManifest) { string webURL = GetPatchManifestRequestURL(_updateResourceVersion, ResourceSettingData.Setting.PatchManifestFileName); - Logger.Log($"Beginning to request patch manifest : {webURL}"); + YooLogger.Log($"Beginning to request patch manifest : {webURL}"); _downloaderManifest = new UnityWebRequester(); _downloaderManifest.SendRequest(webURL, _timeout); _steps = ESteps.CheckWebManifest; @@ -179,7 +179,7 @@ namespace YooAsset _steps = ESteps.Done; Status = EOperationStatus.Succeed; float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime; - Logger.Log($"Verify files total time : {costTime}"); + YooLogger.Log($"Verify files total time : {costTime}"); } } } @@ -205,7 +205,7 @@ namespace YooAsset _impl.LocalPatchManifest = PatchManifest.Deserialize(content); // 注意:这里会覆盖掉沙盒内的补丁清单文件 - Logger.Log("Save remote patch manifest file."); + YooLogger.Log("Save remote patch manifest file."); string savePath = AssetPathHelper.MakePersistentLoadPath(ResourceSettingData.Setting.PatchManifestFileName); PatchManifest.Serialize(savePath, _impl.LocalPatchManifest); } @@ -276,7 +276,7 @@ namespace YooAsset } else { - Logger.Warning("Failed to run verify thread."); + YooLogger.Warning("Failed to run verify thread."); break; } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchAsset.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchAsset.cs index 8d5535a..a3e20d8 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchAsset.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchAsset.cs @@ -3,7 +3,7 @@ namespace YooAsset { [Serializable] - public class PatchAsset + internal class PatchAsset { /// /// 资源路径 diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs index 896aab1..535f3b0 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs @@ -1,11 +1,10 @@ using System; using System.Linq; -using YooAsset.Utility; namespace YooAsset { [Serializable] - public class PatchBundle + internal class PatchBundle { /// /// 资源包名称 diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchCache.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchCache.cs index 52446ec..9bd9a36 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchCache.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchCache.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -using YooAsset.Utility; namespace YooAsset { @@ -22,14 +21,14 @@ namespace YooAsset { if (PatchHelper.CheckSandboxCacheFileExist()) { - Logger.Log("Load patch cache from disk."); + YooLogger.Log("Load patch cache from disk."); string filePath = PatchHelper.GetSandboxCacheFilePath(); string jsonData = FileUtility.ReadFile(filePath); return JsonUtility.FromJson(jsonData); } else { - Logger.Log($"Create patch cache to disk : {Application.version}"); + YooLogger.Log($"Create patch cache to disk : {Application.version}"); PatchCache cache = new PatchCache(); cache.CacheAppVersion = Application.version; string filePath = PatchHelper.GetSandboxCacheFilePath(); @@ -44,7 +43,7 @@ namespace YooAsset /// public static void UpdateCache() { - Logger.Log($"Update patch cache to disk : {Application.version}"); + YooLogger.Log($"Update patch cache to disk : {Application.version}"); PatchCache cache = new PatchCache(); cache.CacheAppVersion = Application.version; string filePath = PatchHelper.GetSandboxCacheFilePath(); diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchHelper.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchHelper.cs index 221f134..8e25edb 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchHelper.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchHelper.cs @@ -1,6 +1,5 @@ using System.IO; using System.Text; -using YooAsset.Utility; namespace YooAsset { diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs index 7815c48..4902264 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs @@ -3,7 +3,6 @@ using System.IO; using System.Collections; using System.Collections.Generic; using UnityEngine; -using YooAsset.Utility; namespace YooAsset { @@ -11,7 +10,7 @@ namespace YooAsset /// 补丁清单文件 /// [Serializable] - public class PatchManifest + internal class PatchManifest { /// /// 资源版本号 @@ -79,7 +78,7 @@ namespace YooAsset } else { - Logger.Warning($"Not found asset path in patch manifest : {assetPath}"); + YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}"); return new string[] { }; } } @@ -104,7 +103,7 @@ namespace YooAsset } else { - Logger.Warning($"Not found asset path in patch manifest : {assetPath}"); + YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}"); return string.Empty; } } @@ -150,7 +149,7 @@ namespace YooAsset { string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath); if (patchManifest.Assets.ContainsKey(assetPathWithoutExtension)) - Logger.Warning($"Asset path have existed : {assetPathWithoutExtension}"); + YooLogger.Warning($"Asset path have existed : {assetPathWithoutExtension}"); else patchManifest.Assets.Add(assetPathWithoutExtension, patchAsset); } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorPlayModeImpl.cs index 817c031..66ddf8d 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorPlayModeImpl.cs @@ -12,7 +12,7 @@ namespace YooAsset public InitializationOperation InitializeAsync() { var operation = new EditorModeInitializationOperation(); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } @@ -27,7 +27,7 @@ namespace YooAsset #region IBundleServices接口 BundleInfo IBundleServices.GetBundleInfo(string bundleName) { - Logger.Warning($"Editor play mode can not get bundle info."); + YooLogger.Warning($"Editor play mode can not get bundle info."); BundleInfo bundleInfo = new BundleInfo(bundleName, bundleName); return bundleInfo; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 6890bf9..6a509a0 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -28,7 +28,7 @@ namespace YooAsset _fallbackHostServer = fallbackHostServer; var operation = new HostPlayModeInitializationOperation(this); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } @@ -38,7 +38,7 @@ namespace YooAsset public UpdateManifestOperation UpdatePatchManifestAsync(int updateResourceVersion, int timeout) { var operation = new HostPlayModeUpdateManifestOperation(this, updateResourceVersion, timeout); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } @@ -284,7 +284,7 @@ namespace YooAsset } else { - Logger.Warning($"Not found bundle in patch manifest : {bundleName}"); + YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}"); BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty); return bundleInfo; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs index 44c2cb7..8d796aa 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs @@ -14,7 +14,7 @@ namespace YooAsset public InitializationOperation InitializeAsync() { var operation = new OfflinePlayModeInitializationOperation(this); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } @@ -42,7 +42,7 @@ namespace YooAsset } else { - Logger.Warning($"Not found bundle in patch manifest : {bundleName}"); + YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}"); BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty); return bundleInfo; } diff --git a/Assets/YooAsset/Runtime/Utility/Misc.meta b/Assets/YooAsset/Runtime/Profiler.meta similarity index 77% rename from Assets/YooAsset/Runtime/Utility/Misc.meta rename to Assets/YooAsset/Runtime/Profiler.meta index 76ecb2d..0efac09 100644 --- a/Assets/YooAsset/Runtime/Utility/Misc.meta +++ b/Assets/YooAsset/Runtime/Profiler.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 778d989dab3088b499eb457a9b7cf854 +guid: 13c0685c8f990994eb8bccb06df93ca3 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/YooAsset/Runtime/Logger/DebugSummy.cs b/Assets/YooAsset/Runtime/Profiler/DebugSummy.cs similarity index 94% rename from Assets/YooAsset/Runtime/Logger/DebugSummy.cs rename to Assets/YooAsset/Runtime/Profiler/DebugSummy.cs index 6a47130..14aa6e3 100644 --- a/Assets/YooAsset/Runtime/Logger/DebugSummy.cs +++ b/Assets/YooAsset/Runtime/Profiler/DebugSummy.cs @@ -29,7 +29,7 @@ namespace YooAsset /// /// 加载状态 /// - public ELoaderStates States { set; get; } + public int States { set; get; } } /// @@ -50,7 +50,7 @@ namespace YooAsset /// /// 加载状态 /// - public EAssetStates States { set; get; } + public int States { set; get; } /// /// 依赖的资源包列表 diff --git a/Assets/YooAsset/Runtime/Logger/DebugSummy.cs.meta b/Assets/YooAsset/Runtime/Profiler/DebugSummy.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Logger/DebugSummy.cs.meta rename to Assets/YooAsset/Runtime/Profiler/DebugSummy.cs.meta diff --git a/Assets/YooAsset/Runtime/Properties.meta b/Assets/YooAsset/Runtime/Properties.meta new file mode 100644 index 0000000..dc77b70 --- /dev/null +++ b/Assets/YooAsset/Runtime/Properties.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2de5a58f37a4ae64e804f150144da809 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs b/Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b076242 --- /dev/null +++ b/Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("YooAsset.Editor")] \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/FileUtility.cs.meta b/Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs.meta similarity index 83% rename from Assets/YooAsset/Runtime/Utility/FileUtility.cs.meta rename to Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs.meta index 835d687..b995713 100644 --- a/Assets/YooAsset/Runtime/Utility/FileUtility.cs.meta +++ b/Assets/YooAsset/Runtime/Properties/AssemblyInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dfc7a106fdf9d90428c38ec09d35a6f3 +guid: a6847b71aba411740aaec06eea58a377 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/YooAsset/Runtime/ResourceSetting.meta b/Assets/YooAsset/Runtime/Settings.meta similarity index 100% rename from Assets/YooAsset/Runtime/ResourceSetting.meta rename to Assets/YooAsset/Runtime/Settings.meta diff --git a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSetting.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs similarity index 85% rename from Assets/YooAsset/Runtime/ResourceSetting/ResourceSetting.cs rename to Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs index 750d592..171f398 100644 --- a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSetting.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs @@ -2,8 +2,8 @@ namespace YooAsset { - [CreateAssetMenu(fileName = "YooAssetSetting", menuName = "YooAsset/Create Setting")] - public class ResourceSetting : ScriptableObject + [CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")] + public class YooAssetSettings : ScriptableObject { /// /// AssetBundle文件的后缀名 diff --git a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSetting.cs.meta b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/ResourceSetting/ResourceSetting.cs.meta rename to Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs.meta diff --git a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSettingData.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs similarity index 50% rename from Assets/YooAsset/Runtime/ResourceSetting/ResourceSettingData.cs rename to Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs index 80df203..3b08f18 100644 --- a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSettingData.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs @@ -4,8 +4,8 @@ namespace YooAsset { public static class ResourceSettingData { - private static ResourceSetting _setting = null; - public static ResourceSetting Setting + private static YooAssetSettings _setting = null; + public static YooAssetSettings Setting { get { @@ -20,15 +20,15 @@ namespace YooAsset /// private static void LoadSettingData() { - _setting = Resources.Load("YooAssetSetting"); + _setting = Resources.Load("YooAssetSettings"); if (_setting == null) { - Debug.Log("Use YooAsset default resource setting."); - _setting = ScriptableObject.CreateInstance(); + YooLogger.Log("YooAsset use default settings."); + _setting = ScriptableObject.CreateInstance(); } else { - Debug.Log("Use YooAsset custom resource setting."); + YooLogger.Log("YooAsset use custom settings."); } } } diff --git a/Assets/YooAsset/Runtime/ResourceSetting/ResourceSettingData.cs.meta b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/ResourceSetting/ResourceSettingData.cs.meta rename to Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs.meta diff --git a/Assets/YooAsset/Runtime/Utility/AssemblyUtility.cs b/Assets/YooAsset/Runtime/Utility/AssemblyUtility.cs deleted file mode 100644 index bd23935..0000000 --- a/Assets/YooAsset/Runtime/Utility/AssemblyUtility.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; - -namespace YooAsset.Utility -{ - public static class AssemblyUtility - { - public const string YooAssetAssemblyName = "YooAsset"; - public const string YooAssetAssemblyEditorName = "YooAsset.Editor"; - public const string UnityDefaultAssemblyName = "Assembly-CSharp"; - public const string UnityDefaultAssemblyEditorName = "Assembly-CSharp-Editor"; - - - private static readonly Dictionary> _cache = new Dictionary>(); - - static AssemblyUtility() - { - _cache.Clear(); - } - - /// - /// 获取程序集 - /// - public static Assembly GetAssembly(string assemblyName) - { - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); - foreach (Assembly assembly in assemblies) - { - if (assembly.GetName().Name == assemblyName) - return assembly; - } - return null; - } - - /// - /// 获取程序集里的所有类型 - /// - private static List GetTypes(string assemblyName) - { - if (_cache.ContainsKey(assemblyName)) - return _cache[assemblyName]; - - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); - foreach (Assembly assembly in assemblies) - { - if (assembly.GetName().Name == assemblyName) - { - List types = assembly.GetTypes().ToList(); - _cache.Add(assemblyName, types); - return types; - } - } - - // 注意:如果没有找到程序集返回空列表 - UnityEngine.Debug.LogWarning($"Not found assembly : {assemblyName}"); - return new List(); - } - - /// - /// 获取带继承关系的所有类的类型 - /// 父类类型 - /// - public static List GetAssignableTypes(string assemblyName, System.Type parentType) - { - List result = new List(); - List cacheTypes = GetTypes(assemblyName); - for (int i = 0; i < cacheTypes.Count; i++) - { - Type type = cacheTypes[i]; - - // 判断继承关系 - if (parentType.IsAssignableFrom(type)) - { - if (type.Name == parentType.Name) - continue; - result.Add(type); - } - } - return result; - } - - /// - /// 获取带属性标签的所有类的类型 - /// 属性类型 - /// - public static List GetAttributeTypes(string assemblyName, System.Type attributeType) - { - List result = new List(); - List cacheTypes = GetTypes(assemblyName); - for (int i = 0; i < cacheTypes.Count; i++) - { - System.Type type = cacheTypes[i]; - - // 判断属性标签 - if (Attribute.IsDefined(type, attributeType)) - { - result.Add(type); - } - } - return result; - } - - /// - /// 获取带继承关系和属性标签的所有类的类型 - /// - /// 父类类型 - /// 属性类型 - public static List GetAssignableAttributeTypes(string assemblyName, System.Type parentType, System.Type attributeType, bool checkError = true) - { - List result = new List(); - List cacheTypes = GetTypes(assemblyName); - for (int i = 0; i < cacheTypes.Count; i++) - { - Type type = cacheTypes[i]; - - // 判断属性标签 - if (Attribute.IsDefined(type, attributeType)) - { - // 判断继承关系 - if (parentType.IsAssignableFrom(type)) - { - if (type.Name == parentType.Name) - continue; - result.Add(type); - } - else - { - if(checkError) - throw new Exception($"class {type} must inherit from {parentType}."); - } - } - } - return result; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/Misc/BitMask32.cs b/Assets/YooAsset/Runtime/Utility/BitMask32.cs similarity index 96% rename from Assets/YooAsset/Runtime/Utility/Misc/BitMask32.cs rename to Assets/YooAsset/Runtime/Utility/BitMask32.cs index d28359e..4e53740 100644 --- a/Assets/YooAsset/Runtime/Utility/Misc/BitMask32.cs +++ b/Assets/YooAsset/Runtime/Utility/BitMask32.cs @@ -1,8 +1,8 @@ using System; -namespace YooAsset.Utility +namespace YooAsset { - public struct BitMask32 + internal struct BitMask32 { private int _mask; diff --git a/Assets/YooAsset/Runtime/Utility/Misc/BitMask32.cs.meta b/Assets/YooAsset/Runtime/Utility/BitMask32.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Utility/Misc/BitMask32.cs.meta rename to Assets/YooAsset/Runtime/Utility/BitMask32.cs.meta diff --git a/Assets/YooAsset/Runtime/Utility/Misc/BitMask64.cs b/Assets/YooAsset/Runtime/Utility/BitMask64.cs similarity index 96% rename from Assets/YooAsset/Runtime/Utility/Misc/BitMask64.cs rename to Assets/YooAsset/Runtime/Utility/BitMask64.cs index 0ad9e31..8bfa729 100644 --- a/Assets/YooAsset/Runtime/Utility/Misc/BitMask64.cs +++ b/Assets/YooAsset/Runtime/Utility/BitMask64.cs @@ -1,8 +1,8 @@ using System; -namespace YooAsset.Utility +namespace YooAsset { - public struct BitMask64 + internal struct BitMask64 { private long _mask; diff --git a/Assets/YooAsset/Runtime/Utility/Misc/BitMask64.cs.meta b/Assets/YooAsset/Runtime/Utility/BitMask64.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Utility/Misc/BitMask64.cs.meta rename to Assets/YooAsset/Runtime/Utility/BitMask64.cs.meta diff --git a/Assets/YooAsset/Runtime/Utility/Misc/CRC32Algorithm.cs b/Assets/YooAsset/Runtime/Utility/CRC32Algorithm.cs similarity index 99% rename from Assets/YooAsset/Runtime/Utility/Misc/CRC32Algorithm.cs rename to Assets/YooAsset/Runtime/Utility/CRC32Algorithm.cs index acb554f..93f38df 100644 --- a/Assets/YooAsset/Runtime/Utility/Misc/CRC32Algorithm.cs +++ b/Assets/YooAsset/Runtime/Utility/CRC32Algorithm.cs @@ -1,7 +1,7 @@ using System; using System.Security.Cryptography; -namespace YooAsset.Utility +namespace YooAsset { internal class SafeProxy { diff --git a/Assets/YooAsset/Runtime/Utility/Misc/CRC32Algorithm.cs.meta b/Assets/YooAsset/Runtime/Utility/CRC32Algorithm.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Utility/Misc/CRC32Algorithm.cs.meta rename to Assets/YooAsset/Runtime/Utility/CRC32Algorithm.cs.meta diff --git a/Assets/YooAsset/Runtime/Utility/FileUtility.cs b/Assets/YooAsset/Runtime/Utility/FileUtility.cs deleted file mode 100644 index 4488d0c..0000000 --- a/Assets/YooAsset/Runtime/Utility/FileUtility.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Text; -using System.IO; - -namespace YooAsset.Utility -{ - public static class FileUtility - { - /// - /// 读取文件 - /// - public static string ReadFile(string filePath) - { - if (File.Exists(filePath) == false) - return string.Empty; - return File.ReadAllText(filePath, Encoding.UTF8); - } - - /// - /// 创建文件 - /// - public static void CreateFile(string filePath, string content) - { - // 删除旧文件 - if (File.Exists(filePath)) - File.Delete(filePath); - - // 创建文件夹路径 - CreateFileDirectory(filePath); - - // 创建新文件 - byte[] bytes = Encoding.UTF8.GetBytes(content); - using (FileStream fs = File.Create(filePath)) - { - fs.Write(bytes, 0, bytes.Length); - fs.Flush(); - fs.Close(); - } - } - - /// - /// 创建文件的文件夹路径 - /// - public static void CreateFileDirectory(string filePath) - { - // 获取文件的文件夹路径 - string directory = Path.GetDirectoryName(filePath); - CreateDirectory(directory); - } - - /// - /// 创建文件夹路径 - /// - public static void CreateDirectory(string directory) - { - // If the directory doesn't exist, create it. - if (Directory.Exists(directory) == false) - Directory.CreateDirectory(directory); - } - - /// - /// 获取文件大小(字节数) - /// - public static long GetFileSize(string filePath) - { - FileInfo fileInfo = new FileInfo(filePath); - return fileInfo.Length; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/HashUtility.cs b/Assets/YooAsset/Runtime/Utility/HashUtility.cs deleted file mode 100644 index 1f1b7a3..0000000 --- a/Assets/YooAsset/Runtime/Utility/HashUtility.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Text; -using System.IO; -using System.Security.Cryptography; - -namespace YooAsset.Utility -{ - public static class HashUtility - { - private static string ToString(byte[] hashBytes) - { - string result = BitConverter.ToString(hashBytes); - result = result.Replace("-", ""); - return result.ToLower(); - } - - #region SHA1 - /// - /// 获取字符串的Hash值 - /// - public static string StringSHA1(string str) - { - byte[] buffer = Encoding.UTF8.GetBytes(str); - return BytesSHA1(buffer); - } - - /// - /// 获取文件的Hash值 - /// - public static string FileSHA1(string filePath) - { - try - { - using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return StreamSHA1(fs); - } - } - catch (Exception e) - { - Logger.Exception(e); - return string.Empty; - } - } - - /// - /// 获取数据流的Hash值 - /// - public static string StreamSHA1(Stream stream) - { - // 说明:创建的是SHA1类的实例,生成的是160位的散列码 - HashAlgorithm hash = HashAlgorithm.Create(); - byte[] hashBytes = hash.ComputeHash(stream); - return ToString(hashBytes); - } - - /// - /// 获取字节数组的Hash值 - /// - public static string BytesSHA1(byte[] buffer) - { - // 说明:创建的是SHA1类的实例,生成的是160位的散列码 - HashAlgorithm hash = HashAlgorithm.Create(); - byte[] hashBytes = hash.ComputeHash(buffer); - return ToString(hashBytes); - } - #endregion - - #region MD5 - /// - /// 获取字符串的MD5 - /// - public static string StringMD5(string str) - { - byte[] buffer = Encoding.UTF8.GetBytes(str); - return BytesMD5(buffer); - } - - /// - /// 获取文件的MD5 - /// - public static string FileMD5(string filePath) - { - try - { - using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return StreamMD5(fs); - } - } - catch (Exception e) - { - Logger.Exception(e); - return string.Empty; - } - } - - /// - /// 获取数据流的MD5 - /// - public static string StreamMD5(Stream stream) - { - MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider(); - byte[] hashBytes = provider.ComputeHash(stream); - return ToString(hashBytes); - } - - /// - /// 获取字节数组的MD5 - /// - public static string BytesMD5(byte[] buffer) - { - MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider(); - byte[] hashBytes = provider.ComputeHash(buffer); - return ToString(hashBytes); - } - #endregion - - #region CRC32 - /// - /// 获取字符串的CRC32 - /// - public static string StringCRC32(string str) - { - byte[] buffer = Encoding.UTF8.GetBytes(str); - return BytesCRC32(buffer); - } - - /// - /// 获取文件的CRC32 - /// - public static string FileCRC32(string filePath) - { - try - { - using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return StreamCRC32(fs); - } - } - catch (Exception e) - { - Logger.Exception(e); - return string.Empty; - } - } - - /// - /// 获取数据流的CRC32 - /// - public static string StreamCRC32(Stream stream) - { - CRC32Algorithm hash = new CRC32Algorithm(); - byte[] hashBytes = hash.ComputeHash(stream); - return ToString(hashBytes); - } - - /// - /// 获取字节数组的CRC32 - /// - public static string BytesCRC32(byte[] buffer) - { - CRC32Algorithm hash = new CRC32Algorithm(); - byte[] hashBytes = hash.ComputeHash(buffer); - return ToString(hashBytes); - } - #endregion - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/HashUtility.cs.meta b/Assets/YooAsset/Runtime/Utility/HashUtility.cs.meta deleted file mode 100644 index ca9d47f..0000000 --- a/Assets/YooAsset/Runtime/Utility/HashUtility.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 43b9656e0b5241e49afcd9d671f5deac -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/Utility/StringUtility.cs b/Assets/YooAsset/Runtime/Utility/StringUtility.cs deleted file mode 100644 index 7b3c203..0000000 --- a/Assets/YooAsset/Runtime/Utility/StringUtility.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Text; -using System.IO; -using System.Collections.Generic; - -namespace YooAsset.Utility -{ - public static class StringUtility - { - [ThreadStatic] - private static StringBuilder _cacheBuilder = new StringBuilder(1024); - - public static string Format(string format, object arg0) - { - if (string.IsNullOrEmpty(format)) - throw new ArgumentNullException(); - - _cacheBuilder.Length = 0; - _cacheBuilder.AppendFormat(format, arg0); - return _cacheBuilder.ToString(); - } - public static string Format(string format, object arg0, object arg1) - { - if (string.IsNullOrEmpty(format)) - throw new ArgumentNullException(); - - _cacheBuilder.Length = 0; - _cacheBuilder.AppendFormat(format, arg0, arg1); - return _cacheBuilder.ToString(); - } - public static string Format(string format, object arg0, object arg1, object arg2) - { - if (string.IsNullOrEmpty(format)) - throw new ArgumentNullException(); - - _cacheBuilder.Length = 0; - _cacheBuilder.AppendFormat(format, arg0, arg1, arg2); - return _cacheBuilder.ToString(); - } - public static string Format(string format, params object[] args) - { - if (string.IsNullOrEmpty(format)) - throw new ArgumentNullException(); - - if (args == null) - throw new ArgumentNullException(); - - _cacheBuilder.Length = 0; - _cacheBuilder.AppendFormat(format, args); - return _cacheBuilder.ToString(); - } - - public static List StringToStringList(string str, char separator) - { - List result = new List(); - if (!String.IsNullOrEmpty(str)) - { - string[] splits = str.Split(separator); - foreach (string split in splits) - { - if (!String.IsNullOrEmpty(split)) - { - result.Add(split); - } - } - } - return result; - } - public static bool StringToBool(string str) - { - int value = (int)Convert.ChangeType(str, typeof(int)); - return value > 0; - } - public static T NameToEnum(string name) - { - if (Enum.IsDefined(typeof(T), name) == false) - { - throw new ArgumentException($"Enum {typeof(T)} is not defined name {name}"); - } - return (T)Enum.Parse(typeof(T), name); - } - - public static string RemoveFirstChar(string str) - { - if (string.IsNullOrEmpty(str)) - return str; - return str.Substring(1); - } - public static string RemoveLastChar(string str) - { - if (string.IsNullOrEmpty(str)) - return str; - return str.Substring(0, str.Length - 1); - } - public static string RemoveExtension(string str) - { - if (string.IsNullOrEmpty(str)) - return str; - - int index = str.LastIndexOf("."); - if (index == -1) - return str; - else - return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test" - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Logger/Logger.cs b/Assets/YooAsset/Runtime/Utility/YooLogger.cs similarity index 94% rename from Assets/YooAsset/Runtime/Logger/Logger.cs rename to Assets/YooAsset/Runtime/Utility/YooLogger.cs index ae27c91..c148a85 100644 --- a/Assets/YooAsset/Runtime/Logger/Logger.cs +++ b/Assets/YooAsset/Runtime/Utility/YooLogger.cs @@ -2,7 +2,7 @@ namespace YooAsset { - internal static class Logger + internal static class YooLogger { /// /// 日志 diff --git a/Assets/YooAsset/Runtime/Logger/Logger.cs.meta b/Assets/YooAsset/Runtime/Utility/YooLogger.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Logger/Logger.cs.meta rename to Assets/YooAsset/Runtime/Utility/YooLogger.cs.meta diff --git a/Assets/YooAsset/Runtime/Utility/YooUtility.cs b/Assets/YooAsset/Runtime/Utility/YooUtility.cs new file mode 100644 index 0000000..dd70302 --- /dev/null +++ b/Assets/YooAsset/Runtime/Utility/YooUtility.cs @@ -0,0 +1,481 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Diagnostics; +using System.Reflection; + +namespace YooAsset +{ + /// + /// 程序集工具类 + /// + internal static class AssemblyUtility + { + public const string YooAssetAssemblyName = "YooAsset"; + public const string YooAssetAssemblyEditorName = "YooAsset.Editor"; + public const string UnityDefaultAssemblyName = "Assembly-CSharp"; + public const string UnityDefaultAssemblyEditorName = "Assembly-CSharp-Editor"; + + + private static readonly Dictionary> _cache = new Dictionary>(); + + static AssemblyUtility() + { + _cache.Clear(); + } + + /// + /// 获取程序集 + /// + public static Assembly GetAssembly(string assemblyName) + { + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach (Assembly assembly in assemblies) + { + if (assembly.GetName().Name == assemblyName) + return assembly; + } + return null; + } + + /// + /// 获取程序集里的所有类型 + /// + private static List GetTypes(string assemblyName) + { + if (_cache.ContainsKey(assemblyName)) + return _cache[assemblyName]; + + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach (Assembly assembly in assemblies) + { + if (assembly.GetName().Name == assemblyName) + { + List types = assembly.GetTypes().ToList(); + _cache.Add(assemblyName, types); + return types; + } + } + + // 注意:如果没有找到程序集返回空列表 + UnityEngine.Debug.LogWarning($"Not found assembly : {assemblyName}"); + return new List(); + } + + /// + /// 获取带继承关系的所有类的类型 + /// 父类类型 + /// + public static List GetAssignableTypes(string assemblyName, System.Type parentType) + { + List result = new List(); + List cacheTypes = GetTypes(assemblyName); + for (int i = 0; i < cacheTypes.Count; i++) + { + Type type = cacheTypes[i]; + + // 判断继承关系 + if (parentType.IsAssignableFrom(type)) + { + if (type.Name == parentType.Name) + continue; + result.Add(type); + } + } + return result; + } + + /// + /// 获取带属性标签的所有类的类型 + /// 属性类型 + /// + public static List GetAttributeTypes(string assemblyName, System.Type attributeType) + { + List result = new List(); + List cacheTypes = GetTypes(assemblyName); + for (int i = 0; i < cacheTypes.Count; i++) + { + System.Type type = cacheTypes[i]; + + // 判断属性标签 + if (Attribute.IsDefined(type, attributeType)) + { + result.Add(type); + } + } + return result; + } + + /// + /// 获取带继承关系和属性标签的所有类的类型 + /// + /// 父类类型 + /// 属性类型 + public static List GetAssignableAttributeTypes(string assemblyName, System.Type parentType, System.Type attributeType, bool checkError = true) + { + List result = new List(); + List cacheTypes = GetTypes(assemblyName); + for (int i = 0; i < cacheTypes.Count; i++) + { + Type type = cacheTypes[i]; + + // 判断属性标签 + if (Attribute.IsDefined(type, attributeType)) + { + // 判断继承关系 + if (parentType.IsAssignableFrom(type)) + { + if (type.Name == parentType.Name) + continue; + result.Add(type); + } + else + { + if(checkError) + throw new Exception($"class {type} must inherit from {parentType}."); + } + } + } + return result; + } + } + + /// + /// 字符串工具类 + /// + internal static class StringUtility + { + [ThreadStatic] + private static StringBuilder _cacheBuilder = new StringBuilder(1024); + + public static string Format(string format, object arg0) + { + if (string.IsNullOrEmpty(format)) + throw new ArgumentNullException(); + + _cacheBuilder.Length = 0; + _cacheBuilder.AppendFormat(format, arg0); + return _cacheBuilder.ToString(); + } + public static string Format(string format, object arg0, object arg1) + { + if (string.IsNullOrEmpty(format)) + throw new ArgumentNullException(); + + _cacheBuilder.Length = 0; + _cacheBuilder.AppendFormat(format, arg0, arg1); + return _cacheBuilder.ToString(); + } + public static string Format(string format, object arg0, object arg1, object arg2) + { + if (string.IsNullOrEmpty(format)) + throw new ArgumentNullException(); + + _cacheBuilder.Length = 0; + _cacheBuilder.AppendFormat(format, arg0, arg1, arg2); + return _cacheBuilder.ToString(); + } + public static string Format(string format, params object[] args) + { + if (string.IsNullOrEmpty(format)) + throw new ArgumentNullException(); + + if (args == null) + throw new ArgumentNullException(); + + _cacheBuilder.Length = 0; + _cacheBuilder.AppendFormat(format, args); + return _cacheBuilder.ToString(); + } + + public static List StringToStringList(string str, char separator) + { + List result = new List(); + if (!String.IsNullOrEmpty(str)) + { + string[] splits = str.Split(separator); + foreach (string split in splits) + { + if (!String.IsNullOrEmpty(split)) + { + result.Add(split); + } + } + } + return result; + } + public static bool StringToBool(string str) + { + int value = (int)Convert.ChangeType(str, typeof(int)); + return value > 0; + } + public static T NameToEnum(string name) + { + if (Enum.IsDefined(typeof(T), name) == false) + { + throw new ArgumentException($"Enum {typeof(T)} is not defined name {name}"); + } + return (T)Enum.Parse(typeof(T), name); + } + + public static string RemoveFirstChar(string str) + { + if (string.IsNullOrEmpty(str)) + return str; + return str.Substring(1); + } + public static string RemoveLastChar(string str) + { + if (string.IsNullOrEmpty(str)) + return str; + return str.Substring(0, str.Length - 1); + } + public static string RemoveExtension(string str) + { + if (string.IsNullOrEmpty(str)) + return str; + + int index = str.LastIndexOf("."); + if (index == -1) + return str; + else + return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test" + } + } + + /// + /// 文件工具类 + /// + internal static class FileUtility + { + /// + /// 读取文件 + /// + public static string ReadFile(string filePath) + { + if (File.Exists(filePath) == false) + return string.Empty; + return File.ReadAllText(filePath, Encoding.UTF8); + } + + /// + /// 创建文件 + /// + public static void CreateFile(string filePath, string content) + { + // 删除旧文件 + if (File.Exists(filePath)) + File.Delete(filePath); + + // 创建文件夹路径 + CreateFileDirectory(filePath); + + // 创建新文件 + byte[] bytes = Encoding.UTF8.GetBytes(content); + using (FileStream fs = File.Create(filePath)) + { + fs.Write(bytes, 0, bytes.Length); + fs.Flush(); + fs.Close(); + } + } + + /// + /// 创建文件的文件夹路径 + /// + public static void CreateFileDirectory(string filePath) + { + // 获取文件的文件夹路径 + string directory = Path.GetDirectoryName(filePath); + CreateDirectory(directory); + } + + /// + /// 创建文件夹路径 + /// + public static void CreateDirectory(string directory) + { + // If the directory doesn't exist, create it. + if (Directory.Exists(directory) == false) + Directory.CreateDirectory(directory); + } + + /// + /// 获取文件大小(字节数) + /// + public static long GetFileSize(string filePath) + { + FileInfo fileInfo = new FileInfo(filePath); + return fileInfo.Length; + } + } + + /// + /// 哈希工具类 + /// + internal static class HashUtility + { + private static string ToString(byte[] hashBytes) + { + string result = BitConverter.ToString(hashBytes); + result = result.Replace("-", ""); + return result.ToLower(); + } + + #region SHA1 + /// + /// 获取字符串的Hash值 + /// + public static string StringSHA1(string str) + { + byte[] buffer = Encoding.UTF8.GetBytes(str); + return BytesSHA1(buffer); + } + + /// + /// 获取文件的Hash值 + /// + public static string FileSHA1(string filePath) + { + try + { + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return StreamSHA1(fs); + } + } + catch (Exception e) + { + YooLogger.Exception(e); + return string.Empty; + } + } + + /// + /// 获取数据流的Hash值 + /// + public static string StreamSHA1(Stream stream) + { + // 说明:创建的是SHA1类的实例,生成的是160位的散列码 + HashAlgorithm hash = HashAlgorithm.Create(); + byte[] hashBytes = hash.ComputeHash(stream); + return ToString(hashBytes); + } + + /// + /// 获取字节数组的Hash值 + /// + public static string BytesSHA1(byte[] buffer) + { + // 说明:创建的是SHA1类的实例,生成的是160位的散列码 + HashAlgorithm hash = HashAlgorithm.Create(); + byte[] hashBytes = hash.ComputeHash(buffer); + return ToString(hashBytes); + } + #endregion + + #region MD5 + /// + /// 获取字符串的MD5 + /// + public static string StringMD5(string str) + { + byte[] buffer = Encoding.UTF8.GetBytes(str); + return BytesMD5(buffer); + } + + /// + /// 获取文件的MD5 + /// + public static string FileMD5(string filePath) + { + try + { + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return StreamMD5(fs); + } + } + catch (Exception e) + { + YooLogger.Exception(e); + return string.Empty; + } + } + + /// + /// 获取数据流的MD5 + /// + public static string StreamMD5(Stream stream) + { + MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider(); + byte[] hashBytes = provider.ComputeHash(stream); + return ToString(hashBytes); + } + + /// + /// 获取字节数组的MD5 + /// + public static string BytesMD5(byte[] buffer) + { + MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider(); + byte[] hashBytes = provider.ComputeHash(buffer); + return ToString(hashBytes); + } + #endregion + + #region CRC32 + /// + /// 获取字符串的CRC32 + /// + public static string StringCRC32(string str) + { + byte[] buffer = Encoding.UTF8.GetBytes(str); + return BytesCRC32(buffer); + } + + /// + /// 获取文件的CRC32 + /// + public static string FileCRC32(string filePath) + { + try + { + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return StreamCRC32(fs); + } + } + catch (Exception e) + { + YooLogger.Exception(e); + return string.Empty; + } + } + + /// + /// 获取数据流的CRC32 + /// + public static string StreamCRC32(Stream stream) + { + CRC32Algorithm hash = new CRC32Algorithm(); + byte[] hashBytes = hash.ComputeHash(stream); + return ToString(hashBytes); + } + + /// + /// 获取字节数组的CRC32 + /// + public static string BytesCRC32(byte[] buffer) + { + CRC32Algorithm hash = new CRC32Algorithm(); + byte[] hashBytes = hash.ComputeHash(buffer); + return ToString(hashBytes); + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Utility/AssemblyUtility.cs.meta b/Assets/YooAsset/Runtime/Utility/YooUtility.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Utility/AssemblyUtility.cs.meta rename to Assets/YooAsset/Runtime/Utility/YooUtility.cs.meta diff --git a/Assets/YooAsset/Runtime/YooAsset.asmdef b/Assets/YooAsset/Runtime/YooAsset.asmdef index f3b53a8..d906ae1 100644 --- a/Assets/YooAsset/Runtime/YooAsset.asmdef +++ b/Assets/YooAsset/Runtime/YooAsset.asmdef @@ -1,10 +1,9 @@ { "name": "YooAsset", - "rootNamespace": "", "references": [], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": true, + "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 0690ee9..52a6e96 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -135,7 +135,7 @@ namespace YooAsset if (parameters.AssetLoadingMaxNumber < 3) { parameters.AssetLoadingMaxNumber = 3; - Logger.Warning($"{nameof(parameters.AssetLoadingMaxNumber)} minimum is 3"); + YooLogger.Warning($"{nameof(parameters.AssetLoadingMaxNumber)} minimum is 3"); } // 创建间隔计时器 @@ -200,13 +200,13 @@ namespace YooAsset if (_playMode == EPlayMode.EditorPlayMode) { var operation = new EditorModeUpdateManifestOperation(); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } else if (_playMode == EPlayMode.OfflinePlayMode) { var operation = new OfflinePlayModeUpdateManifestOperation(); - OperationUpdater.ProcessOperaiton(operation); + OperationSystem.ProcessOperaiton(operation); return operation; } else if (_playMode == EPlayMode.HostPlayMode) @@ -284,7 +284,7 @@ namespace YooAsset public static void GetDebugSummy(DebugSummy summy) { if (summy == null) - Logger.Error($"{nameof(DebugSummy)} is null"); + YooLogger.Error($"{nameof(DebugSummy)} is null"); AssetSystem.GetDebugSummy(summy); } @@ -507,7 +507,7 @@ namespace YooAsset /// public static void ClearSandbox() { - Logger.Warning("Clear sandbox."); + YooLogger.Warning("Clear sandbox."); PatchHelper.ClearSandbox(); } @@ -527,7 +527,7 @@ namespace YooAsset internal static void InternalUpdate() { // 更新异步请求操作 - OperationUpdater.Update(); + OperationSystem.Update(); // 更新下载管理系统 DownloadSystem.Update();