Update AssetSystem

pull/9/head
hevinci 2022-05-02 17:54:55 +08:00
parent 873d873194
commit 8d02406211
4 changed files with 33 additions and 33 deletions

View File

@ -23,7 +23,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
throw new System.Exception($"{nameof(AssetOperationHandle)} is invalid"); throw new System.Exception($"{nameof(AssetOperationHandle)} is invalid");
if (_provider.IsDone) if (Provider.IsDone)
value.Invoke(this); value.Invoke(this);
else else
_callback += value; _callback += value;
@ -45,7 +45,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return null; return null;
return _provider.AssetObject; return Provider.AssetObject;
} }
} }
@ -56,7 +56,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return; return;
_provider.WaitForAsyncComplete(); Provider.WaitForAsyncComplete();
} }
/// <summary> /// <summary>
@ -114,22 +114,22 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return null; return null;
if (_provider.AssetObject == null) if (Provider.AssetObject == null)
return null; return null;
if (setPositionRotation) if (setPositionRotation)
{ {
if (parent == null) if (parent == null)
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation); return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation);
else else
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation, parent); return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
} }
else else
{ {
if (parent == null) if (parent == null)
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject); return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject);
else else
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, parent); return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
} }
} }
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation) private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)

View File

@ -5,11 +5,11 @@ namespace YooAsset
public abstract class OperationHandleBase : IEnumerator public abstract class OperationHandleBase : IEnumerator
{ {
private readonly string _cachedAssetPath; private readonly string _cachedAssetPath;
internal ProviderBase _provider { private set; get; } internal ProviderBase Provider { private set; get; }
internal OperationHandleBase(ProviderBase provider) internal OperationHandleBase(ProviderBase provider)
{ {
_provider = provider; Provider = provider;
_cachedAssetPath = provider.AssetPath; _cachedAssetPath = provider.AssetPath;
} }
internal abstract void InvokeCallback(); internal abstract void InvokeCallback();
@ -23,9 +23,9 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return EOperationStatus.None; return EOperationStatus.None;
if (_provider.Status == ProviderBase.EStatus.Fail) if (Provider.Status == ProviderBase.EStatus.Fail)
return EOperationStatus.Failed; return EOperationStatus.Failed;
else if (_provider.Status == ProviderBase.EStatus.Success) else if (Provider.Status == ProviderBase.EStatus.Success)
return EOperationStatus.Succeed; return EOperationStatus.Succeed;
else else
return EOperationStatus.None; return EOperationStatus.None;
@ -41,7 +41,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return string.Empty; return string.Empty;
return _provider.LastError; return Provider.LastError;
} }
} }
@ -54,7 +54,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return 0; return 0;
return _provider.Progress; return Provider.Progress;
} }
} }
@ -67,7 +67,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return false; return false;
return _provider.IsDone; return Provider.IsDone;
} }
} }
@ -78,15 +78,15 @@ namespace YooAsset
{ {
get get
{ {
if (_provider != null && _provider.IsDestroyed == false) if (Provider != null && Provider.IsDestroyed == false)
{ {
return true; return true;
} }
else else
{ {
if (_provider == null) if (Provider == null)
YooLogger.Warning($"Operation handle is released : {_cachedAssetPath}"); YooLogger.Warning($"Operation handle is released : {_cachedAssetPath}");
else if (_provider.IsDestroyed) else if (Provider.IsDestroyed)
YooLogger.Warning($"Provider is destroyed : {_cachedAssetPath}"); YooLogger.Warning($"Provider is destroyed : {_cachedAssetPath}");
return false; return false;
} }
@ -100,8 +100,8 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return; return;
_provider.ReleaseHandle(this); Provider.ReleaseHandle(this);
_provider = null; Provider = null;
} }
#region 异步操作相关 #region 异步操作相关
@ -110,7 +110,7 @@ namespace YooAsset
/// </summary> /// </summary>
public System.Threading.Tasks.Task Task public System.Threading.Tasks.Task Task
{ {
get { return _provider.Task; } get { return Provider.Task; }
} }
// 协程相关 // 协程相关
@ -123,7 +123,7 @@ namespace YooAsset
} }
object IEnumerator.Current object IEnumerator.Current
{ {
get { return _provider; } get { return Provider; }
} }
#endregion #endregion
} }

View File

@ -23,7 +23,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
throw new System.Exception($"{nameof(SceneOperationHandle)} is invalid"); throw new System.Exception($"{nameof(SceneOperationHandle)} is invalid");
if (_provider.IsDone) if (Provider.IsDone)
value.Invoke(this); value.Invoke(this);
else else
_callback += value; _callback += value;
@ -45,7 +45,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return new Scene(); return new Scene();
return _provider.SceneObject; return Provider.SceneObject;
} }
} }
@ -76,14 +76,14 @@ namespace YooAsset
if (IsValid == false) if (IsValid == false)
return false; return false;
if (_provider is DatabaseSceneProvider) if (Provider is DatabaseSceneProvider)
{ {
var temp = _provider as DatabaseSceneProvider; var temp = Provider as DatabaseSceneProvider;
return temp.SceneMode == LoadSceneMode.Single; return temp.SceneMode == LoadSceneMode.Single;
} }
else if (_provider is BundledSceneProvider) else if (Provider is BundledSceneProvider)
{ {
var temp = _provider as BundledSceneProvider; var temp = Provider as BundledSceneProvider;
return temp.SceneMode == LoadSceneMode.Single; return temp.SceneMode == LoadSceneMode.Single;
} }
else else
@ -118,7 +118,7 @@ namespace YooAsset
// 卸载子场景 // 卸载子场景
Scene sceneObject = SceneObject; Scene sceneObject = SceneObject;
AssetSystem.UnloadSubScene(_provider); AssetSystem.UnloadSubScene(Provider);
{ {
var operation = new UnloadSceneOperation(sceneObject); var operation = new UnloadSceneOperation(sceneObject);
OperationSystem.ProcessOperaiton(operation); OperationSystem.ProcessOperaiton(operation);

View File

@ -22,7 +22,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
throw new System.Exception($"{nameof(SubAssetsOperationHandle)} is invalid"); throw new System.Exception($"{nameof(SubAssetsOperationHandle)} is invalid");
if (_provider.IsDone) if (Provider.IsDone)
value.Invoke(this); value.Invoke(this);
else else
_callback += value; _callback += value;
@ -44,7 +44,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return null; return null;
return _provider.AllAssetObjects; return Provider.AllAssetObjects;
} }
} }
@ -55,7 +55,7 @@ namespace YooAsset
{ {
if (IsValid == false) if (IsValid == false)
return; return;
_provider.WaitForAsyncComplete(); Provider.WaitForAsyncComplete();
} }
/// <summary> /// <summary>
@ -77,7 +77,7 @@ namespace YooAsset
if (IsValid == false) if (IsValid == false)
return null; return null;
foreach (var asset in _provider.AllAssetObjects) foreach (var asset in Provider.AllAssetObjects)
{ {
if (asset.name == assetName) if (asset.name == assetName)
return asset as TObject; return asset as TObject;