DatabaseRawFileProvider.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 
  2. namespace YooAsset
  3. {
  4. internal class DatabaseRawFileProvider : ProviderBase
  5. {
  6. public DatabaseRawFileProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
  7. {
  8. }
  9. public override void Update()
  10. {
  11. #if UNITY_EDITOR
  12. if (IsDone)
  13. return;
  14. if (Status == EStatus.None)
  15. {
  16. // 检测资源文件是否存在
  17. string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
  18. if (string.IsNullOrEmpty(guid))
  19. {
  20. Status = EStatus.Failed;
  21. LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
  22. YooLogger.Error(LastError);
  23. InvokeCompletion();
  24. return;
  25. }
  26. Status = EStatus.CheckBundle;
  27. // 注意:模拟异步加载效果提前返回
  28. if (IsWaitForAsyncComplete == false)
  29. return;
  30. }
  31. // 1. 检测资源包
  32. if (Status == EStatus.CheckBundle)
  33. {
  34. if (IsWaitForAsyncComplete)
  35. {
  36. OwnerBundle.WaitForAsyncComplete();
  37. }
  38. if (OwnerBundle.IsDone() == false)
  39. return;
  40. if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
  41. {
  42. Status = EStatus.Failed;
  43. LastError = OwnerBundle.LastError;
  44. InvokeCompletion();
  45. return;
  46. }
  47. Status = EStatus.Checking;
  48. }
  49. // 2. 检测加载结果
  50. if (Status == EStatus.Checking)
  51. {
  52. RawFilePath = MainAssetInfo.AssetPath;
  53. Status = EStatus.Succeed;
  54. InvokeCompletion();
  55. }
  56. #endif
  57. }
  58. }
  59. }