I’m attempting to run a headless instance of Unity 3.5.7f6 which executes a static method that collects assets and passes them to BuildPipeline.BuildAssetBundle().
Assuming my project is at /tmp/BundlerProject
/Applications/Unity/Unity.app/Content/MacOS/Unity -batchmode -quit -projectPath /tmp/BundlerProject -executeMethod AssetsBundler.Bundle
Assume my <project_dir>/Assets/ directory contains Foo.fbx and FooTexture.jpg
The AssetsBundler.Bundle method looks like this:
public static class AssetsBundler {
public static void Bundle() {
List<string> assetPaths = new List<string>();
assetPaths.Add("Assets/Foo.fbx");
assetPaths.Add("Assets/FooTexture.jpg");
List<UnityEngine.Object> assetList = new List<UnityEngine.Object>();
foreach (string assetPath in assetPaths) {
assetList.AddRange( AssetDatabase.LoadAllAssetsAtPath(assetPath) );
}
UnityEngine.Object[] assets = assetList.ToArray();
BuildPipeline.BuildAssetBundle(null, assets, "MyBundle.unity3d", BuildAssetBundleOptions.CompleteAssets, BuildTarget.WebPlayer);
}
}
And this is the error i see in the logs:
Aborting batchmode due to failure:
Fatal error! GetManagerFromContext: pointer to object of manager 'PlayerSettings' is NULL (table index 0)
UnityEditor.BuildPipeline:BuildAssetBundle(Object, Object[], String, BuildAssetBundleOptions, BuildTarget)
AssetsBundler:Bundle() (at Assets/Editor/AssetsBundler.cs:140)
It seems everything up until the error works as it should. I’ve added logs to determine the assets are imported correctly, so it appears that it’s a problem with running this particular method in batchmode.
Does anyone have any insight into the problem or a possible work-around? Gotta love the inability to debug failures in generating proprietary formats! :: Aggravated :::