I hope it’s not too late.
If you don’t want the process of manually exporting Blender to FBX, this is the solution.
(If you already have a bunch of blender files in your project,This solution may mess up your current project , so make sure you have a backup!)
1.Set the blender you want Unity to use as the default Blender file launcher for Windows (if you have multiple versions of Blender)
2.{The address where your UnityEditor was installed}\6000.0.30f1{Your UnityEditor Version}\Editor\Data\Tools\Unity-BlenderToFBX.py
Change the content to(Yes,Unity’s script for calling Blender is wrong, I don’t know from what version.)
def export_args():
return {
# These options seem to produce the same result as the old Ascii exporter in Unity3D:
"axis_up": 'Y',
"axis_forward": '-Z',
"global_matrix": Matrix.Rotation(-math.pi / 2.0, 4, 'X'),
# Should really be True, but it can cause problems if a model is already in a scene or prefab
# with the old transforms.
"bake_space_transform": True, <==These have been modified by me
"apply_scale_options": 'FBX_SCALE_ALL',
"use_selection": False,
"object_types": {'ARMATURE', 'EMPTY', 'MESH', 'OTHER'},
"use_mesh_modifiers": True,
"use_mesh_modifiers_render": True,
"use_mesh_edges": False,
"mesh_smooth_type": 'FACE',
"use_subsurf": False,
"use_tspace": False, # XXX Why? Unity is expected to support tspace import...
"use_triangles": False,
"use_armature_deform_only": False,
"use_custom_props": True,
"bake_anim": True,<==These have been modified by me
"bake_anim_simplify_factor": 1.0,
"bake_anim_step": 1.0,
"bake_anim_use_nla_strips": True,<==These have been modified by me
"bake_anim_use_all_actions": False,<==These have been modified by me
"add_leaf_bones": False, # Avoid memory/performance cost for something only useful for modelling
"primary_bone_axis": 'Y', # Doesn't really matter for Unity, so leave unchanged
"secondary_bone_axis": 'X',
"path_mode": 'AUTO',
"embed_textures": False,
"batch_mode": 'OFF',
}
try:
import bpy
import io_scene_fbx.export_fbx_bin
import sys
argv = sys.argv
outfile = ' '.join(argv[argv.index("--") + 1:])
import math
from mathutils import Matrix
mtx4_x90n = Matrix.Rotation(-math.pi / 2.0, 4, 'X')
class FakeOp:
def report(self, tp, msg):
print("%s: %s" % (tp, msg))
kwargs = export_args()
io_scene_fbx.export_fbx_bin.save(FakeOp(), bpy.context, filepath=outfile, **kwargs)
print("Finished blender to FBX conversion " + outfile)
except Exception as e:
print('error: io_scene_fbx.export_fbx not found.')
Have fun
