ResourceHelper.cs 480 B

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