From 015f09d27befdfd667487a4ff840d55691191a06 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 23 Nov 2022 12:33:12 +0800 Subject: [PATCH] Update runtime code --- .../Handles/AssetOperationHandle.cs | 12 +++--- .../Handles/OperationHandleBase.cs | 38 +++++++++---------- .../Handles/RawFileOperationHandle.cs | 12 +++--- .../Handles/SceneOperationHandle.cs | 12 +++--- .../Handles/SubAssetsOperationHandle.cs | 12 +++--- .../Operations/InstantiateOperation.cs | 2 +- .../AssetSystem/Provider/ProviderBase.cs | 2 +- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs index c0783b7..2bbc916 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs @@ -22,7 +22,7 @@ namespace YooAsset { add { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(AssetOperationHandle)} is invalid"); if (Provider.IsDone) value.Invoke(this); @@ -31,7 +31,7 @@ namespace YooAsset } remove { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(AssetOperationHandle)} is invalid"); _callback -= value; } @@ -44,7 +44,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return null; return Provider.AssetObject; } @@ -56,7 +56,7 @@ namespace YooAsset /// 资源类型 public TAsset GetAssetObject() where TAsset : UnityEngine.Object { - if (IsValid == false) + if (IsValidWithWarning == false) return null; return Provider.AssetObject as TAsset; } @@ -66,7 +66,7 @@ namespace YooAsset /// public void WaitForAsyncComplete() { - if (IsValid == false) + if (IsValidWithWarning == false) return; Provider.WaitForAsyncComplete(); } @@ -124,7 +124,7 @@ namespace YooAsset private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent) { - if (IsValid == false) + if (IsValidWithWarning == false) return null; if (Provider.AssetObject == null) return null; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs index a6d3713..d6185e7 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs @@ -30,7 +30,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return EOperationStatus.None; if (Provider.Status == ProviderBase.EStatus.Fail) return EOperationStatus.Failed; @@ -48,7 +48,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return string.Empty; return Provider.LastError; } @@ -61,7 +61,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return 0; return Provider.Progress; } @@ -74,7 +74,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return false; return Provider.IsDone; } @@ -84,6 +84,20 @@ namespace YooAsset /// 句柄是否有效 /// public bool IsValid + { + get + { + if (Provider != null && Provider.IsDestroyed == false) + return true; + else + return false; + } + } + + /// + /// 句柄是否有效 + /// + internal bool IsValidWithWarning { get { @@ -102,26 +116,12 @@ namespace YooAsset } } - /// - /// 句柄是否有效 - /// - public bool IsValidNoWarning - { - get - { - if (Provider != null && Provider.IsDestroyed == false) - return true; - else - return false; - } - } - /// /// 释放句柄 /// internal void ReleaseInternal() { - if (IsValid == false) + if (IsValidWithWarning == false) return; Provider.ReleaseHandle(this); Provider = null; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs index fd31eef..08d244c 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs @@ -22,7 +22,7 @@ namespace YooAsset { add { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(RawFileOperationHandle)} is invalid"); if (Provider.IsDone) value.Invoke(this); @@ -31,7 +31,7 @@ namespace YooAsset } remove { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(RawFileOperationHandle)} is invalid"); _callback -= value; } @@ -42,7 +42,7 @@ namespace YooAsset /// public void WaitForAsyncComplete() { - if (IsValid == false) + if (IsValidWithWarning == false) return; Provider.WaitForAsyncComplete(); } @@ -61,7 +61,7 @@ namespace YooAsset /// public byte[] GetRawFileData() { - if (IsValid == false) + if (IsValidWithWarning == false) return null; string filePath = Provider.RawFilePath; if (File.Exists(filePath) == false) @@ -74,7 +74,7 @@ namespace YooAsset /// public string GetRawFileText() { - if (IsValid == false) + if (IsValidWithWarning == false) return null; string filePath = Provider.RawFilePath; if (File.Exists(filePath) == false) @@ -87,7 +87,7 @@ namespace YooAsset /// public string GetRawFilePath() { - if (IsValid == false) + if (IsValidWithWarning == false) return string.Empty; return Provider.RawFilePath; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs index 983565c..4f15206 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs @@ -22,7 +22,7 @@ namespace YooAsset { add { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(SceneOperationHandle)} is invalid"); if (Provider.IsDone) value.Invoke(this); @@ -31,7 +31,7 @@ namespace YooAsset } remove { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(SceneOperationHandle)} is invalid"); _callback -= value; } @@ -44,7 +44,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return new Scene(); return Provider.SceneObject; } @@ -55,7 +55,7 @@ namespace YooAsset /// public bool ActivateScene() { - if (IsValid == false) + if (IsValidWithWarning == false) return false; if (SceneObject.IsValid() && SceneObject.isLoaded) @@ -74,7 +74,7 @@ namespace YooAsset /// public bool IsMainScene() { - if (IsValid == false) + if (IsValidWithWarning == false) return false; if (Provider is DatabaseSceneProvider) @@ -99,7 +99,7 @@ namespace YooAsset public UnloadSceneOperation UnloadAsync() { // 如果句柄无效 - if (IsValid == false) + if (IsValidWithWarning == false) { string error = $"{nameof(SceneOperationHandle)} is invalid."; var operation = new UnloadSceneOperation(error); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs index 9418057..59ee557 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs @@ -21,7 +21,7 @@ namespace YooAsset { add { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(SubAssetsOperationHandle)} is invalid"); if (Provider.IsDone) value.Invoke(this); @@ -30,7 +30,7 @@ namespace YooAsset } remove { - if (IsValid == false) + if (IsValidWithWarning == false) throw new System.Exception($"{nameof(SubAssetsOperationHandle)} is invalid"); _callback -= value; } @@ -43,7 +43,7 @@ namespace YooAsset { get { - if (IsValid == false) + if (IsValidWithWarning == false) return null; return Provider.AllAssetObjects; } @@ -54,7 +54,7 @@ namespace YooAsset /// public void WaitForAsyncComplete() { - if (IsValid == false) + if (IsValidWithWarning == false) return; Provider.WaitForAsyncComplete(); } @@ -75,7 +75,7 @@ namespace YooAsset /// 子资源对象名称 public TObject GetSubAssetObject(string assetName) where TObject : UnityEngine.Object { - if (IsValid == false) + if (IsValidWithWarning == false) return null; foreach (var assetObject in Provider.AllAssetObjects) @@ -94,7 +94,7 @@ namespace YooAsset /// 子资源对象类型 public TObject[] GetSubAssetObjects() where TObject : UnityEngine.Object { - if (IsValid == false) + if (IsValidWithWarning == false) return null; List ret = new List(Provider.AllAssetObjects.Length); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs index 49ebcc2..76b39b8 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs @@ -41,7 +41,7 @@ namespace YooAsset if (_steps == ESteps.Clone) { - if (_handle.IsValid == false) + if (_handle.IsValidWithWarning == false) { _steps = ESteps.Done; Status = EOperationStatus.Failed; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index fc2e61c..6e1c991 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -223,7 +223,7 @@ namespace YooAsset List tempers = new List(_handles); foreach (var hande in tempers) { - if (hande.IsValid) + if (hande.IsValidWithWarning) { hande.InvokeCallback(); }