ResourceHelper.cs 504 B

123456789101112131415161718192021
  1. #if UNITY_EDITOR
  2. using UnityEditor;
  3. #endif
  4. using UnityEngine;
  5. namespace Model
  6. {
  7. public static class ResourceHelper
  8. {
  9. public static UnityEngine.Object LoadResource(string bundleName, string prefab)
  10. {
  11. #if UNITY_EDITOR
  12. string[] realPath = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(bundleName.ToLower() + ".unity3d", prefab);
  13. UnityEngine.Object resource = AssetDatabase.LoadAssetAtPath(realPath[0], typeof(GameObject));
  14. return resource;
  15. #else
  16. return null;
  17. #endif
  18. }
  19. }
  20. }