I made this addon to have a better control over mesh data exported from Blender to Unity3D. Additionally it improved speed of iterations.
Initially script had no UI elements. But I offered my script to my friend and to make his life easier I decided to update it and make UI for it.
Addon handles export of all meshes which are linked under an export_node (helper object). One export_node creates a one FBX file.
Other features were added such as custom properties which are processed by Unity3D’s AssetProcessor while meshes are imported. Required fields such as name of the FBX file and export path are saved within the .blender file as meta data.
Additionally I added preprocessor script which is responsible for adding collider components on individual meshes in Unity3D and converting individual meshes to Unity Collider objects [BoxCollider, CyllinderCollider, etc.].
Functionality is quite simple: Link all meshes you want to export as a one object under export_node. You can do it either in 3d viewport or in Scene Collection panel. Fill up name for export node (which will translate as name of your FBX file), pick export path and hit export button.
Name: Name of FBX file
Path: Where FBX file is going to be saved
isStatic: Custom property
Export to FBX: Button that exports meshes linked under this export node
Create a new export node: When a mesh is selected in 3D viewport or in Scene Collection panel and button is pressed, it creates a new empty export node (helper object) in a position of your selection.
Colliders: If user wants to export also collider objects together with the mesh they can do so by naming collider meshes with specified suffixes: boxcollider, capsulecollider, spherecollider, _coll(static mesh).
Flags: Additionally you can set isStatic boolean. This boolean sets a custom property to all objects under your export_node to static. When your object is imported to Unity3D this custom property is read and all objects within are flagged by Unity3D editor as Static.
Static flag in Unity3D editor: BatchingStatic, ContributeGI, ContributeGI, OccludeeStatic, OccluderStatic, ReflectionProbeStatic
Although FBX exporter is not responsible for seting any in-editor flags. AssetPostprocessor.cs
is responsible for it:
private void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] propNames, System.Object[] values) {
string metaKeyStatic = "isStatic";
for (int i = 0; i < propNames.Length; i++) {
if (System.String.Equals(propNames[i], metaKeyStatic) && (int)values[i] == 1) {
GameObjectUtility.SetStaticEditorFlags(go, flags);
}
}
}
Link to repository: GitHub Link.