we build our scenes as AssetBundles. The export script loads the scene, does some customization to the scene, gets the root GameObject and creates an AssetBundle from it.
Because we create some new GameObjects during the customization of the scene we have to create them as assets and save them to file, because Unity can’t build objects that aren’t located on disk.
So in short the script does
load the level
customizes the level
– creates new GameObjects
– saves every GameObject as asset using AssetDatabase.CreateAsset()
gets the root GameObject and builds an AssetBundle from it using BuildPipeline.BuildAssetBundle()
Now this works. But, we get lots of these errors: “Inconsistent asset when sorting preload assets: ‘’ fileID: 0”
We get this error because we’ve created some assets (customization of the scene) but Unity hasn’t imported them. Also when we force refreshing / importing assets it doesn’t work since somehow it doesn’t import the new assets. It only works when we refresh ALL assets using ImportAssetOptions.ForceUpdate, but you can image that this takes loooong.
So when we load this AssetBundle it sometimes crashes Unity complete.
Does somebody has any idea how we can solve this problem?