Update runtime code

pull/51/head
hevinci 2022-11-23 12:33:12 +08:00
parent 3fedc5b1b3
commit 015f09d27b
7 changed files with 45 additions and 45 deletions

View File

@ -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
/// <typeparam name="TAsset">资源类型</typeparam>
public TAsset GetAssetObject<TAsset>() where TAsset : UnityEngine.Object
{
if (IsValid == false)
if (IsValidWithWarning == false)
return null;
return Provider.AssetObject as TAsset;
}
@ -66,7 +66,7 @@ namespace YooAsset
/// </summary>
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;

View File

@ -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
/// 句柄是否有效
/// </summary>
public bool IsValid
{
get
{
if (Provider != null && Provider.IsDestroyed == false)
return true;
else
return false;
}
}
/// <summary>
/// 句柄是否有效
/// </summary>
internal bool IsValidWithWarning
{
get
{
@ -102,26 +116,12 @@ namespace YooAsset
}
}
/// <summary>
/// 句柄是否有效
/// </summary>
public bool IsValidNoWarning
{
get
{
if (Provider != null && Provider.IsDestroyed == false)
return true;
else
return false;
}
}
/// <summary>
/// 释放句柄
/// </summary>
internal void ReleaseInternal()
{
if (IsValid == false)
if (IsValidWithWarning == false)
return;
Provider.ReleaseHandle(this);
Provider = null;

View File

@ -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
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValid == false)
if (IsValidWithWarning == false)
return;
Provider.WaitForAsyncComplete();
}
@ -61,7 +61,7 @@ namespace YooAsset
/// </summary>
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
/// </summary>
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
/// </summary>
public string GetRawFilePath()
{
if (IsValid == false)
if (IsValidWithWarning == false)
return string.Empty;
return Provider.RawFilePath;
}

View File

@ -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
/// </summary>
public bool ActivateScene()
{
if (IsValid == false)
if (IsValidWithWarning == false)
return false;
if (SceneObject.IsValid() && SceneObject.isLoaded)
@ -74,7 +74,7 @@ namespace YooAsset
/// </summary>
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);

View File

@ -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
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValid == false)
if (IsValidWithWarning == false)
return;
Provider.WaitForAsyncComplete();
}
@ -75,7 +75,7 @@ namespace YooAsset
/// <param name="assetName">子资源对象名称</param>
public TObject GetSubAssetObject<TObject>(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
/// <typeparam name="TObject">子资源对象类型</typeparam>
public TObject[] GetSubAssetObjects<TObject>() where TObject : UnityEngine.Object
{
if (IsValid == false)
if (IsValidWithWarning == false)
return null;
List<TObject> ret = new List<TObject>(Provider.AllAssetObjects.Length);

View File

@ -41,7 +41,7 @@ namespace YooAsset
if (_steps == ESteps.Clone)
{
if (_handle.IsValid == false)
if (_handle.IsValidWithWarning == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;

View File

@ -223,7 +223,7 @@ namespace YooAsset
List<OperationHandleBase> tempers = new List<OperationHandleBase>(_handles);
foreach (var hande in tempers)
{
if (hande.IsValid)
if (hande.IsValidWithWarning)
{
hande.InvokeCallback();
}