Parcourir la source

修复打包报错的问题

tanghai il y a 8 ans
Parent
commit
586f26d459
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  1. 4 0
      Unity/Assets/Scripts/Helper/ResourceHelper.cs

+ 4 - 0
Unity/Assets/Scripts/Helper/ResourceHelper.cs

@@ -7,9 +7,13 @@ namespace Model
 	{
 	{
 		public static UnityEngine.Object LoadResource(string bundleName, string prefab)
 		public static UnityEngine.Object LoadResource(string bundleName, string prefab)
 		{
 		{
+#if  UNITY_EDITOR
 			string[] realPath = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(bundleName.ToLower() + ".unity3d", prefab);
 			string[] realPath = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(bundleName.ToLower() + ".unity3d", prefab);
 			UnityEngine.Object resource = AssetDatabase.LoadAssetAtPath(realPath[0], typeof(GameObject));
 			UnityEngine.Object resource = AssetDatabase.LoadAssetAtPath(realPath[0], typeof(GameObject));
 			return resource;
 			return resource;
+#else
+			return null;
+#endif
 		}
 		}
 	}
 	}
 }
 }