AssetBundle Creation Problem

Hello,

I have a script that creates a prefab in order to create an AssetBundle from it (this part of the Unity API is really a mess!!!).

My script runs perfectly the first time but crash with the following error the second time:

Inconsistent asset when sorting preload assets: '' fileID: 0
UnityEditor.BuildPipeline:BuildAssetBundleInternal(Object, Object[], String[], String, BuildAssetBundleOptions, BuildTarget)
UnityEditor.BuildPipeline:BuildAssetBundle(Object, Object[], String, BuildAssetBundleOptions, BuildTarget) (at C:\BuildAgent\work\842f9557127e852\Editor\MonoGenerated\Editor\BuildPipeline.cs:55)

Here a the code I use to create the AssetBundle:

var prefab = EditorUtility.CreateEmptyPrefab("myPrefab.prefab");
        EditorUtility.ReplacePrefab(myObject.gameObject, prefab, ReplacePrefabOptions.ConnectToPrefab);
        AssetDatabase.Refresh();
        BuildPipeline.BuildAssetBundle(AssetDatabase.LoadMainAssetAtPath("myPrefab.prefab"), null, "myBundle.unity3d", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows64);
        AssetDatabase.Refresh();

My gameobject is a simple Asset model in my project.

If you have any clue please share ;-)!

Thx

I think that the reason of my problem was that the second time, I was creating an AssetBundle of a prefab created from an AssetBundle… I’ve changed my design to not do that. And now it works…

Perhaps you are having the same issue from this post.
Hope it helps!