- Home /
How to avoid getting: "Asset bundles can not include Editor Objects (AssetMetaData)" error message
When I use:
UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath("Assets/test3/test-img.png");
Debug.Log(objs.Length);
BuildPipeline.BuildAssetBundle(null, objs, Application.dataPath + "/../bundle.test");
I get:
- "2"
- "Asset bundles can not include Editor Objects (AssetMetaData): assets/test3/test-img.png."
Maybe using AssetDatabase.LoadMainAssetAtPath() would help but I am not using neither BuildAssetBundleOptions.CollectDependencies nor BuildAssetBundleOptions.CompleteAssets.
Also AssetDatabase.LoadAssetAtPath() would not help because it requires a datatype.
(Actually I know how to solve this, but is so annoying that I decided to post it).
Answer by Daniel Sperry 2 · Apr 06, 2010 at 04:21 PM
Considering that istead of a png, the asset may be anything, I circunvent this the following way:
UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath("Assets/test3/test-img.png"); UnityEngine.Object[] objs2 = new UnityEngine.Object[objs.Length]; Debug.Log(objs.Length);
for (int i = 0, j = 0; i < objs.Length; i++)
if (objs[i].GetType() != typeof(UnityEngine.Object))
objs2[j++] = objs[i];
BuildPipeline.BuildAssetBundle(null, objs2, Application.dataPath + "/../bundle.test");
Maybe using AssetDatabase.LoadMainAssetAtPath() would help but I am not using neither BuildAssetBundleOptions.CollectDependencies nor BuildAssetBundleOptions.CompleteAssets.
Your answer
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
C++ Error After Automated Build 1 Answer
How can I stop the variable values reverting to its default values after being built? 1 Answer
WebGl build error cannot build player while editor is importing assets or compiling scripts 0 Answers