Update AssetSystem

This commit is contained in:
hevinci
2022-03-23 12:44:56 +08:00
parent 3e8b8123e1
commit 829b4fca76
17 changed files with 265 additions and 129 deletions
@@ -62,9 +62,9 @@ namespace YooAsset
if (IsWaitForAsyncComplete)
{
if (AssetType == null)
AllAssets = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName);
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName);
else
AllAssets = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName, AssetType);
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName, AssetType);
}
else
{
@@ -85,17 +85,17 @@ namespace YooAsset
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity asset.");
AllAssets = _cacheRequest.allAssets;
AllAssetObjects = _cacheRequest.allAssets;
}
else
{
if (_cacheRequest.isDone == false)
return;
AllAssets = _cacheRequest.allAssets;
AllAssetObjects = _cacheRequest.allAssets;
}
}
Status = AllAssets == null ? EStatus.Fail : EStatus.Success;
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
InvokeCompletion();
@@ -52,7 +52,7 @@ namespace YooAsset
{
if (AssetType == null)
{
AllAssets = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetPath);
AllAssetObjects = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetPath);
}
else
{
@@ -63,7 +63,7 @@ namespace YooAsset
if (findAsset.GetType() == AssetType)
result.Add(findAsset);
}
AllAssets = result.ToArray();
AllAssetObjects = result.ToArray();
}
Status = EStatus.Checking;
}
@@ -71,7 +71,7 @@ namespace YooAsset
// 2. 检测加载结果
if (Status == EStatus.Checking)
{
Status = AllAssets == null ? EStatus.Fail : EStatus.Success;
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load sub assets : {AssetName}");
InvokeCompletion();
@@ -38,7 +38,7 @@ namespace YooAsset
/// <summary>
/// 获取的资源对象集合
/// </summary>
public UnityEngine.Object[] AllAssets { protected set; get; }
public UnityEngine.Object[] AllAssetObjects { protected set; get; }
/// <summary>
/// 获取的场景对象
@@ -210,7 +210,7 @@ namespace YooAsset
}
}
// 异步操作相关
#region 异步编程相关
private System.Threading.EventWaitHandle _waitHandle;
private System.Threading.WaitHandle WaitHandle
{
@@ -230,5 +230,6 @@ namespace YooAsset
}
_waitHandle?.Set();
}
#endregion
}
}