- Home /
Importing assets that need pre-processing (like .blend) from the Unity commadline for a CI Server
I am setting up a CI server for our unity project and I am running into a problem with assets that must be imported and pre processed by unity. Specifically .blend files. What I've made so far produces a web build of the project at the location I expect, however it appears the .blend files we have within the project aren't getting imported into Unity before it builds. Any assets that already are .fbx files are working fine. I'm aware that Unity actually ends up using blender to import these files (or other programs based on the other types you put into the project directories) and I'm wondering if there is a way I can make sure it does its import step involving other programs, like blender. The machine working from the command line has blender installed, and can import and build the project properly, if done so manually from the unity editor.
If there isn't an easy way to do this, I am wondering if there is a way to call the same functionality that Unity uses to prepare the assets myself. I recognize that python files are used in importing the assets using blender, for example : `Unity/Editor/Data/Tools/Unity-BlenderToFBX.py` However I don't really know python, and I'm unsure where to begin trying to determine how I would do this step outside of Unity, while making sure I use the same process unity does (The whole point is the test that these files will import and build properly through a fresh check out and with the unity editor) Any information or suggestions to help me achieve my goal would be much appreciated.
Here's more specifics about the automated build process
Checking out the files for the project from svn
Creating a new Unity Project from the command line
Adding the files checked out into the project
Running Unity from the command line with these arguments: `-batchMode -quit -nographics -executeMethod AutoBuilder.PerformWebBuild`
AutoBuilder looks like this:
public class AutoBuilder
{
private const string NAME = "name";
private const string TARGET_DIR = "target";
[MenuItem ("Custom/CI/Web Build")]
public static void PerformWebBuild()
{
//AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
string locationPathName = TARGET_DIR + "/" + NAME;
string[] scenes = FindEnabledEditorScenes();
string res = BuildPipeline.BuildPlayer(scenes, locationPathName, BuildTarget.WebPlayer, BuildOptions.None);
if (res.Length > 0)
{
throw new Exception("BuildPlayer failure: " + res);
}
}
private static string[] FindEnabledEditorScenes()
{
List<string> EditorScenes = new List<string>();
foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
if (!scene.enabled) continue;
EditorScenes.Add(scene.path);
}
return EditorScenes.ToArray();
}
}
I have tried running `AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);` before beginning a build in hopes it would import blend files , but it does not. Also, there is absolutely no mention of working with any of the .blend files in the unity log, that also includes errors importing them.
Answer by sed · Nov 17, 2015 at 10:46 AM
I know it's "a bit" too late for the answer to be helpful to you. So just for the record:
You could use additional step between 3 and 4 to convert all .blend files to .fbx for that you could use a blender installation and run it in the command line / bash / terminal mode.
You can find the python code here: https://github.com/iamsed/blendToFbxExporterForUnity