AssetDatabaseLoader.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using XRTool.Util;
  6. #if UNITY_EDITOR
  7. using UnityEditor;
  8. namespace ShadowStudio.Util
  9. {
  10. public class AssetDatabaseLoader : Singleton<AssetDatabaseLoader>, DataLoad
  11. {
  12. public UnityEngine.Object Load(string path)
  13. {
  14. return AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object));
  15. }
  16. public T Load<T>(string path) where T : UnityEngine.Object
  17. {
  18. return AssetDatabase.LoadAssetAtPath<T>(path);
  19. }
  20. public UnityEngine.Object Load(string path, Type systemTypeInstance)
  21. {
  22. return AssetDatabase.LoadAssetAtPath(path, systemTypeInstance);
  23. }
  24. public T[] LoadAll<T>(string path) where T : UnityEngine.Object
  25. {
  26. return (T[])AssetDatabase.LoadAllAssetsAtPath(path);
  27. }
  28. public UnityEngine.Object[] LoadAll(string path, Type systemTypeInstance)
  29. {
  30. return AssetDatabase.LoadAllAssetsAtPath(path);
  31. }
  32. public UnityEngine.Object[] LoadAll(string path)
  33. {
  34. return AssetDatabase.LoadAllAssetsAtPath(path);
  35. }
  36. public LoadInfo LoadAsync<T>(string path) where T : UnityEngine.Object
  37. {
  38. LoadInfo info = new LoadInfo();
  39. var obj = Load<T>(path);
  40. info.progress = 1;
  41. info.isDone = true;
  42. info.asset = obj;
  43. return info;
  44. }
  45. public LoadInfo LoadAsync(string path)
  46. {
  47. LoadInfo info = new LoadInfo();
  48. var obj = Load(path);
  49. info.progress = 1;
  50. info.isDone = true;
  51. info.asset = obj;
  52. return info;
  53. }
  54. public LoadInfo LoadAsync(string path, Type type)
  55. {
  56. throw new NotImplementedException();
  57. }
  58. public void UnloadAllAsset()
  59. {
  60. }
  61. public void UnloadAsset(UnityEngine.Object assetToUnload)
  62. {
  63. }
  64. }
  65. }
  66. #endif