Update YooAsset

This commit is contained in:
hevinci
2022-03-09 23:57:04 +08:00
parent 1c7b90806c
commit a00924bb54
39 changed files with 283 additions and 369 deletions
@@ -1,122 +0,0 @@
using System.IO;
namespace YooAsset
{
internal static class AssetPathHelper
{
/// <summary>
/// 获取规范化的路径
/// </summary>
public static string GetRegularPath(string path)
{
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
}
/// <summary>
/// 获取文件所在的目录路径(Linux格式)
/// </summary>
public static string GetDirectory(string filePath)
{
string directory = Path.GetDirectoryName(filePath);
return GetRegularPath(directory);
}
/// <summary>
/// 获取基于流文件夹的加载路径
/// </summary>
public static string MakeStreamingLoadPath(string path)
{
return StringUtility.Format("{0}/{1}", UnityEngine.Application.streamingAssetsPath, path);
}
/// <summary>
/// 获取基于沙盒文件夹的加载路径
/// </summary>
public static string MakePersistentLoadPath(string path)
{
string root = MakePersistentRootPath();
return StringUtility.Format("{0}/{1}", root, path);
}
/// <summary>
/// 获取沙盒文件夹路径
/// </summary>
public static string MakePersistentRootPath()
{
#if UNITY_EDITOR
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
string projectPath = GetDirectory(UnityEngine.Application.dataPath);
return StringUtility.Format("{0}/Sandbox", projectPath);
#else
return StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath);
#endif
}
/// <summary>
/// 获取网络资源加载路径
/// </summary>
public static string ConvertToWWWPath(string path)
{
// 注意:WWW加载方式,必须要在路径前面加file://
#if UNITY_EDITOR
return StringUtility.Format("file:///{0}", path);
#elif UNITY_IPHONE
return StringUtility.Format("file://{0}", path);
#elif UNITY_ANDROID
return path;
#elif UNITY_STANDALONE
return StringUtility.Format("file:///{0}", path);
#endif
}
/// <summary>
/// 合并资源路径
/// </summary>
internal static string CombineAssetPath(string root, string location)
{
if (string.IsNullOrEmpty(root))
return location;
else
return $"{root}/{location}";
}
/// <summary>
/// 获取AssetDatabase的加载路径
/// </summary>
internal static string FindDatabaseAssetPath(string filePath)
{
#if UNITY_EDITOR
if (File.Exists(filePath))
return filePath;
// AssetDatabase加载资源需要提供文件后缀格式,然而资源定位地址并没有文件格式信息。
// 所以我们通过查找该文件所在文件夹内同名的首个文件来确定AssetDatabase的加载路径。
// 注意:AssetDatabase.FindAssets() 返回文件内包括递归文件夹内所有资源的GUID
string fileName = Path.GetFileName(filePath);
string directory = GetDirectory(filePath);
string[] guids = UnityEditor.AssetDatabase.FindAssets(string.Empty, new[] { directory });
for (int i = 0; i < guids.Length; i++)
{
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[i]);
if (UnityEditor.AssetDatabase.IsValidFolder(assetPath))
continue;
string assetDirectory = GetDirectory(assetPath);
if (assetDirectory != directory)
continue;
string assetName = Path.GetFileNameWithoutExtension(assetPath);
if (assetName == fileName)
return assetPath;
}
// 没有找到同名的资源文件
YooLogger.Warning($"Not found asset : {filePath}");
return filePath;
#else
throw new System.NotImplementedException();
#endif
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9581e7c53fe081749ab849ec6e2be3d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -20,7 +20,7 @@ namespace YooAsset
/// </summary>
public static int AssetLoadingMaxNumber { private set; get; }
public static IDecryptServices DecryptServices { private set; get; }
public static IDecryptionServices DecryptionServices { private set; get; }
public static IBundleServices BundleServices { private set; get; }
@@ -28,11 +28,11 @@ namespace YooAsset
/// 初始化资源系统
/// 注意:在使用AssetSystem之前需要初始化
/// </summary>
public static void Initialize(bool simulationOnEditor, int assetLoadingMaxNumber, IDecryptServices decryptServices, IBundleServices bundleServices)
public static void Initialize(bool simulationOnEditor, int assetLoadingMaxNumber, IDecryptionServices decryptionServices, IBundleServices bundleServices)
{
SimulationOnEditor = simulationOnEditor;
AssetLoadingMaxNumber = assetLoadingMaxNumber;
DecryptServices = decryptServices;
DecryptionServices = decryptionServices;
BundleServices = bundleServices;
}
@@ -307,7 +307,7 @@ namespace YooAsset
DebugSummy.DebugProviderInfo providerInfo = new DebugSummy.DebugProviderInfo();
providerInfo.AssetPath = provider.AssetPath;
providerInfo.RefCount = provider.RefCount;
providerInfo.States = (int)provider.States;
providerInfo.Status = (int)provider.Status;
providerInfo.BundleInfos.Clear();
summy.ProviderInfos.Add(providerInfo);
@@ -1,19 +0,0 @@
namespace YooAsset
{
/// <summary>
/// 解密方法
/// </summary>
public enum EDecryptMethod
{
/// <summary>
/// 获取解密的数据偏移
/// </summary>
GetDecryptOffset,
/// <summary>
/// 获取解密的字节数据
/// </summary>
GetDecryptBinary,
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6a446add12cd4554a9bd178a7ef2db55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,18 +0,0 @@
namespace YooAsset
{
public interface IDecryptServices
{
EDecryptMethod DecryptType { get; }
/// <summary>
/// 获取解密的数据偏移
/// </summary>
ulong GetDecryptOffset(BundleInfo bundleInfo);
/// <summary>
/// 获取解密的字节数据
/// </summary>
byte[] GetDecryptBinary(BundleInfo bundleInfo);
}
}
@@ -0,0 +1,11 @@
namespace YooAsset
{
public interface IDecryptionServices
{
/// <summary>
/// 获取加密文件的数据偏移量
/// </summary>
ulong GetFileOffset(BundleInfo bundleInfo);
}
}
@@ -7,6 +7,17 @@ namespace YooAsset
{
internal class BundleFileLoader
{
public enum EStatus
{
None = 0,
Download,
CheckDownload,
LoadFile,
CheckFile,
Success,
Fail,
}
/// <summary>
/// 资源包文件信息
/// </summary>
@@ -20,7 +31,7 @@ namespace YooAsset
/// <summary>
/// 加载状态
/// </summary>
public ELoaderStates States { private set; get; }
public EStatus Status { private set; get; }
/// <summary>
/// 是否已经销毁
@@ -33,13 +44,13 @@ namespace YooAsset
private FileDownloader _fileDownloader;
private AssetBundleCreateRequest _cacheRequest;
internal AssetBundle CacheBundle { private set; get; }
public BundleFileLoader(BundleInfo bundleInfo)
{
BundleFileInfo = bundleInfo;
RefCount = 0;
States = ELoaderStates.None;
Status = EStatus.None;
}
/// <summary>
@@ -89,31 +100,31 @@ namespace YooAsset
if (IsDone())
return;
if (States == ELoaderStates.None)
if (Status == EStatus.None)
{
// 检测加载地址是否为空
if (string.IsNullOrEmpty(BundleFileInfo.LocalPath))
{
States = ELoaderStates.Fail;
Status = EStatus.Fail;
return;
}
if (string.IsNullOrEmpty(BundleFileInfo.RemoteMainURL))
States = ELoaderStates.LoadFile;
Status = EStatus.LoadFile;
else
States = ELoaderStates.Download;
Status = EStatus.Download;
}
// 1. 从服务器下载
if (States == ELoaderStates.Download)
if (Status == EStatus.Download)
{
int failedTryAgain = int.MaxValue;
_fileDownloader = DownloadSystem.BeginDownload(BundleFileInfo, failedTryAgain);
States = ELoaderStates.CheckDownload;
Status = EStatus.CheckDownload;
}
// 2. 检测服务器下载结果
if (States == ELoaderStates.CheckDownload)
if (Status == EStatus.CheckDownload)
{
if (_fileDownloader.IsDone() == false)
return;
@@ -121,23 +132,23 @@ namespace YooAsset
if (_fileDownloader.HasError())
{
_fileDownloader.ReportError();
States = ELoaderStates.Fail;
Status = EStatus.Fail;
}
else
{
States = ELoaderStates.LoadFile;
Status = EStatus.LoadFile;
}
}
// 3. 加载AssetBundle
if (States == ELoaderStates.LoadFile)
if (Status == EStatus.LoadFile)
{
#if UNITY_EDITOR
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
if (System.IO.File.Exists(BundleFileInfo.LocalPath) == false)
{
YooLogger.Warning($"Not found assetBundle file : {BundleFileInfo.LocalPath}");
States = ELoaderStates.Fail;
Status = EStatus.Fail;
return;
}
#endif
@@ -145,30 +156,14 @@ namespace YooAsset
// Load assetBundle file
if (BundleFileInfo.IsEncrypted)
{
if (AssetSystem.DecryptServices == null)
if (AssetSystem.DecryptionServices == null)
throw new Exception($"{nameof(BundleFileLoader)} need IDecryptServices : {BundleFileInfo.BundleName}");
EDecryptMethod decryptType = AssetSystem.DecryptServices.DecryptType;
if (decryptType == EDecryptMethod.GetDecryptOffset)
{
ulong offset = AssetSystem.DecryptServices.GetDecryptOffset(BundleFileInfo);
if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath, 0, offset);
else
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath, 0, offset);
}
else if (decryptType == EDecryptMethod.GetDecryptBinary)
{
byte[] binary = AssetSystem.DecryptServices.GetDecryptBinary(BundleFileInfo);
if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromMemory(binary);
else
_cacheRequest = AssetBundle.LoadFromMemoryAsync(binary);
}
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath, 0, offset);
else
{
throw new NotImplementedException($"{decryptType}");
}
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath, 0, offset);
}
else
{
@@ -177,11 +172,11 @@ namespace YooAsset
else
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath);
}
States = ELoaderStates.CheckFile;
Status = EStatus.CheckFile;
}
// 4. 检测AssetBundle加载结果
if (States == ELoaderStates.CheckFile)
if (Status == EStatus.CheckFile)
{
if (_cacheRequest != null)
{
@@ -203,11 +198,11 @@ namespace YooAsset
if (CacheBundle == null)
{
YooLogger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}");
States = ELoaderStates.Fail;
Status = EStatus.Fail;
}
else
{
States = ELoaderStates.Success;
Status = EStatus.Success;
}
}
}
@@ -240,7 +235,7 @@ namespace YooAsset
/// </summary>
public bool IsDone()
{
return States == ELoaderStates.Success || States == ELoaderStates.Fail;
return Status == EStatus.Success || Status == EStatus.Fail;
}
/// <summary>
@@ -302,7 +297,7 @@ namespace YooAsset
if (_isShowWaitForAsyncError == false)
{
_isShowWaitForAsyncError = true;
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {States}");
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {Status}");
}
break;
}
@@ -74,7 +74,7 @@ namespace YooAsset
debugInfo.BundleName = loader.BundleFileInfo.BundleName;
debugInfo.Version = loader.BundleFileInfo.Version;
debugInfo.RefCount = loader.RefCount;
debugInfo.States = (int)loader.States;
debugInfo.Status = (int)loader.Status;
output.Add(debugInfo);
}
}
@@ -1,17 +0,0 @@
namespace YooAsset
{
/// <summary>
/// 文件加载器状态
/// </summary>
public enum ELoaderStates
{
None = 0,
Download,
CheckDownload,
LoadFile,
CheckFile,
Success,
Fail,
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 90f00fe388279034aaee9c89c07e2ef1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fcfac83df022948478c32bf11b8e0987
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -24,15 +24,20 @@ namespace YooAsset
}
/// <summary>
/// 当前的加载状态
/// 当前状态
/// </summary>
public EAssetStates States
public EOperationStatus Status
{
get
{
if (IsValid == false)
return EAssetStates.None;
return _provider.States;
return EOperationStatus.None;
if (_provider.Status == AssetProviderBase.EStatus.Fail)
return EOperationStatus.Failed;
else if (_provider.Status == AssetProviderBase.EStatus.Success)
return EOperationStatus.Succeed;
else
return EOperationStatus.None;
}
}
@@ -3,6 +3,16 @@ namespace YooAsset
{
internal abstract class AssetProviderBase : IAssetProvider
{
public enum EStatus
{
None = 0,
CheckBundle,
Loading,
Checking,
Success,
Fail,
}
protected bool IsWaitForAsyncComplete { private set; get; } = false;
public string AssetPath { private set; get; }
@@ -11,7 +21,7 @@ namespace YooAsset
public UnityEngine.Object AssetObject { protected set; get; }
public UnityEngine.Object[] AllAssets { protected set; get; }
public IAssetInstance AssetInstance { protected set; get; }
public EAssetStates States { protected set; get; }
public EStatus Status { protected set; get; }
public int RefCount { private set; get; }
public AssetOperationHandle Handle { private set; get; }
public System.Action<AssetOperationHandle> Callback { set; get; }
@@ -20,7 +30,7 @@ namespace YooAsset
{
get
{
return States == EAssetStates.Success || States == EAssetStates.Fail;
return Status == EStatus.Success || Status == EStatus.Fail;
}
}
public bool IsValid
@@ -44,7 +54,7 @@ namespace YooAsset
AssetPath = assetPath;
AssetName = System.IO.Path.GetFileName(assetPath);
AssetType = assetType;
States = EAssetStates.None;
Status = EStatus.None;
Handle = new AssetOperationHandle(this);
}
@@ -26,13 +26,13 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
States = EAssetStates.CheckBundle;
Status = EStatus.CheckBundle;
}
// 1. 检测资源包
if (States == EAssetStates.CheckBundle)
if (Status == EStatus.CheckBundle)
{
if (IsWaitForAsyncComplete)
{
@@ -47,17 +47,17 @@ namespace YooAsset
if (OwnerBundle.CacheBundle == null)
{
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
}
else
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
}
// 2. 加载资源对象
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
if (IsWaitForAsyncComplete)
{
@@ -73,11 +73,11 @@ namespace YooAsset
else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(AssetName, AssetType);
}
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
// 3. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
if (_cacheRequest != null)
{
@@ -95,8 +95,8 @@ namespace YooAsset
}
}
States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success;
if (States == EAssetStates.Fail)
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
InvokeCompletion();
}
@@ -42,7 +42,7 @@ namespace YooAsset
ownerInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName;
ownerInfo.Version = OwnerBundle.BundleFileInfo.Version;
ownerInfo.RefCount = OwnerBundle.RefCount;
ownerInfo.States = (int)OwnerBundle.States;
ownerInfo.Status = (int)OwnerBundle.Status;
output.Add(ownerInfo);
DependBundles.GetBundleDebugInfos(output);
@@ -29,13 +29,13 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
States = EAssetStates.CheckBundle;
Status = EStatus.CheckBundle;
}
// 1. 检测资源包
if (States == EAssetStates.CheckBundle)
if (Status == EStatus.CheckBundle)
{
if (DependBundles.IsDone() == false)
return;
@@ -44,34 +44,34 @@ namespace YooAsset
if (OwnerBundle.CacheBundle == null)
{
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
}
else
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
}
// 2. 加载场景
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
_asyncOp = SceneManager.LoadSceneAsync(AssetName, _param.LoadMode);
if (_asyncOp != null)
{
_asyncOp.allowSceneActivation = true;
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
else
{
YooLogger.Warning($"Failed to load scene : {AssetName}");
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
}
}
// 3. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
if (_asyncOp.isDone)
{
@@ -81,7 +81,7 @@ namespace YooAsset
if (_param.ActivateOnLoad)
instance.Activate();
States = instance.Scene.IsValid() ? EAssetStates.Success : EAssetStates.Fail;
Status = instance.Scene.IsValid() ? EStatus.Success : EStatus.Fail;
InvokeCompletion();
}
}
@@ -26,13 +26,13 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
States = EAssetStates.CheckBundle;
Status = EStatus.CheckBundle;
}
// 1. 检测资源包
if (States == EAssetStates.CheckBundle)
if (Status == EStatus.CheckBundle)
{
if (IsWaitForAsyncComplete)
{
@@ -47,17 +47,17 @@ namespace YooAsset
if (OwnerBundle.CacheBundle == null)
{
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
}
else
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
}
// 2. 加载资源对象
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
if (IsWaitForAsyncComplete)
{
@@ -73,11 +73,11 @@ namespace YooAsset
else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(AssetName, AssetType);
}
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
// 3. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
if (_cacheRequest != null)
{
@@ -95,8 +95,8 @@ namespace YooAsset
}
}
States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success;
if (States == EAssetStates.Fail)
Status = AllAssets == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
InvokeCompletion();
}
@@ -27,19 +27,19 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
if (string.IsNullOrEmpty(guid))
{
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
return;
}
else
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
// 注意:模拟异步加载效果提前返回
@@ -48,17 +48,17 @@ namespace YooAsset
}
// 1. 加载资源对象
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(AssetPath, AssetType);
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
// 2. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success;
if (States == EAssetStates.Fail)
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load asset object : {AssetPath}");
InvokeCompletion();
}
@@ -28,13 +28,13 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
// 1. 加载资源对象
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
loadSceneParameters.loadSceneMode = _param.LoadMode;
@@ -42,18 +42,18 @@ namespace YooAsset
if (_asyncOp != null)
{
_asyncOp.allowSceneActivation = true;
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
else
{
YooLogger.Warning($"Failed to load scene : {AssetName}");
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
}
}
// 2. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
if (_asyncOp.isDone)
{
@@ -63,7 +63,7 @@ namespace YooAsset
if(_param.ActivateOnLoad)
instance.Activate();
States = instance.Scene.IsValid() ? EAssetStates.Success : EAssetStates.Fail;
Status = instance.Scene.IsValid() ? EStatus.Success : EStatus.Fail;
InvokeCompletion();
}
}
@@ -27,19 +27,19 @@ namespace YooAsset
if (IsDone)
return;
if (States == EAssetStates.None)
if (Status == EStatus.None)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
if (string.IsNullOrEmpty(guid))
{
States = EAssetStates.Fail;
Status = EStatus.Fail;
InvokeCompletion();
return;
}
else
{
States = EAssetStates.Loading;
Status = EStatus.Loading;
}
// 注意:模拟异步加载效果提前返回
@@ -48,7 +48,7 @@ namespace YooAsset
}
// 1. 加载资源对象
if (States == EAssetStates.Loading)
if (Status == EStatus.Loading)
{
var findAssets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(AssetPath);
List<UnityEngine.Object> result = new List<Object>(findAssets.Length);
@@ -58,14 +58,14 @@ namespace YooAsset
result.Add(findObj);
}
AllAssets = result.ToArray();
States = EAssetStates.Checking;
Status = EStatus.Checking;
}
// 2. 检测加载结果
if (States == EAssetStates.Checking)
if (Status == EStatus.Checking)
{
States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success;
if (States == EAssetStates.Fail)
Status = AllAssets == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail)
YooLogger.Warning($"Failed to load all asset object : {AssetPath}");
InvokeCompletion();
}
@@ -1,16 +0,0 @@
namespace YooAsset
{
/// <summary>
/// 资源加载状态
/// </summary>
public enum EAssetStates
{
None = 0,
CheckBundle,
Loading,
Checking,
Success,
Fail,
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: aa6c0fe63326c604bb699be16747c1e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -39,7 +39,7 @@ namespace YooAsset
/// <summary>
/// 当前的加载状态
/// </summary>
EAssetStates States { get; }
AssetProviderBase.EStatus Status { get; }
/// <summary>
/// 引用计数