Im working on an EditorScript that dynamically imports an FBX, and then builds an AssetBundle from this FBX. However, when I load in the AssetBundle, the meshes are all missing.
GameObject _prefab = PrefabUtility.SaveAsPrefabAssetAndConnect(
_FBX_Asset,
"Assets/_Imports/test.prefab",
InteractionMode.AutomatedAction);
string assetPath = AssetDatabase.GetAssetPath(_prefab);
AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant("testbundle", "");
BuildPipeline.BuildAssetBundles(
"Assets/_AssetBundles",
BuildAssetBundleOptions.None,
BuildTarget.StandaloneOSX);
And to load, I use;
var myLoadedAssetBundle = AssetBundle.LoadFromFile("Assets/_AssetBundles/testbundle");
GameObject[] prefab = myLoadedAssetBundle.LoadAllAssets();
for(int i = 0; i < prefab.Length; i++)
{
Instantiate(prefab[i]);
}
What am I missing here?
↧