Unity can not load the fbx file directly, but can load the obj file at runtime, you can convert fbx file to obj files.
- Convert fbx to obj files with command line script.
- Load obj at Unity runtime.
One way to convert fbx/dae to obj is using Blender command line, so you should installed Blender (support platform: Linux, Mac, Windows).
Create this python file:
import bpy
import sys
for obj in bpy.data.objects:
if (obj.name == "Lamp") | (obj.name == "Camera") | (obj.name == "Cube"):
obj.select = False
else:
obj.select = True
argv = sys.argv
argv = argv[argv.index("--") + 1:]
inputpath = argv[0]
outputpath = argv[1]
bpy.ops.import_scene.fbx(filepath=inputpath, axis_forward='-Z', axis_up='Y', directory="", filter_glob="*.fbx", ui_tab='MAIN', use_manual_orientation=False, global_scale=1, bake_space_transform=False, use_custom_normals=True, use_image_search=True, use_alpha_decals=False, decal_offset=0, use_anim=True, anim_offset=1, use_custom_props=True, use_custom_props_enum_as_string=True, ignore_leaf_bones=False, force_connect_children=False, automatic_bone_orientation=False, primary_bone_axis='Y', secondary_bone_axis='X', use_prepost_rot=True)
bpy.ops.export_scene.obj(filepath=outputpath, check_existing=False, axis_forward='-Z', axis_up='Y', filter_glob="*.obj;*.mtl", use_selection=True, use_animation=False, use_mesh_modifiers=True, use_mesh_modifiers_render=False, use_edges=True, use_smooth_groups=False, use_smooth_groups_bitflags=False, use_normals=True, use_uvs=True, use_materials=True, use_triangles=False, use_nurbs=False, use_vertex_groups=False, use_blen_objects=True, group_by_object=False, group_by_material=False, keep_vertex_order=False, global_scale=1, path_mode='COPY')
print("finished!")
Run this file in shell:
/your blender path/blender --background --python /your python path/convert.py -- /your input path/xxx.fbx /your output path/xxx.obj
Finally, use this plugin to load obj files at run time:
https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547
More about blender command line to import and export files: https://blender.stackexchange.com/questions/16563/how-can-i-run-blender-from-the-command-line-to-export-and-import-models