There are two ways to import .blend models into Unity:
- export the specific models you need as FBX from Blender, import the FBX
- import the whole .blend file, ignore the parts you don’t need
Both of these have significant workflow hurdles. The first is not automatic, so can be a source of errors in addition to taking extra effort, but it has a huge advantage over the second method: you only need to import the game-ready assets, not high-poly models that are not to be used from Unity and which slow the import significantly.
In the past, we would kludge the Unity-BlenderToFBX.py to skip certain assets, based on tags in the name or by using the hide_render Blender object property. Both of these are ugly kludges, and I don’t think anyone ever suggested Unity should do it that way.
With the Collections feature of Blender 2.8 however, there’s an opportunity to do a much better job.
Currently, I’m using a modified Unity-BlenderToFBX.py that excludes all assets in a collection named “Aux”, and it works extremely well. Ideally, the Blender ModelImporter would show a list of Collections and allow them to be toggled on and off.
For those interested, this is the relevant code snippet:
if blender280:
import bpy.ops
render = []
override = bpy.context.copy()
exclude = set()
for c in bpy.data.collections:
if c.name == "Aux":
for obj in c.all_objects:
exclude.add(obj)
if len(exclude) == 0:
# Better way: import anything not in the Aux collection:
for obj in bpy.context.view_layer.objects:
if not obj.hide_render:
render.append(obj)
else:
# Kludge way: skip objects which don't have the Render flag set:
for obj in bpy.context.view_layer.objects:
if obj not in exclude:
render.append(obj)
override['selected_objects'] = render # select objects to be exported
bpy.ops.export_scene.fbx(
override,
filepath=outfile,
check_existing=False,
use_selection=True, # USe the selection set above
use_active_collection=False,