Ignoring certain objects on blender import

Hi! My .blend files all have extra objects in them like scaling references and lights and cameras for blender’s renderer and such, which I really don’t need or want in unity. Heck, I don’t need it to import the high-poly meshes when doing normal baking either, but I don’t want to remvove those from the file.

I’d like to make the blender importer drop any imported item that starts with a “.” or something like that, so I can basically in blender mark things to be ignored by unity.

I’m fairly sure this can be achieved with the post-import scripting option but I really don’t know what a good way to go about doing it is as i’ve barely started learning unity’s APIs.

Thanks!

After discovering that the scirpt unity uses to tell blender what to do is laying around in unity/editor/data/tools, I made this little hack to it to implement my own solution:

--- Unity-BlenderToFBX.py.orig	2014-05-13 01:03:46.000000000 -0700
+++ Unity-BlenderToFBX.py	2014-07-30 13:25:00.913891600 -0700
@@ -71,7 +71,12 @@
 			BATCH_OWN_DIR=False)
 	else:
 		# 2.59 and later
+		# WVR HACKUMS HERE
+		for obj in bpy.data.objects:
+			obj.select = False if obj.name[0] in '_.' else True
+
 		kwargs = io_scene_fbx.export_fbx.defaults_unity3d()
+		kwargs["use_selection"] = True
 		io_scene_fbx.export_fbx.save(FakeOp(), bpy.context, filepath=outfile, **kwargs)
 	# HQ normals are not supported in the current exporter
  1. Never import blender (or maya, 3dsmax) files into Unity directly. Always import fbx files.
    Reasons :
    a) Unity actually can’t import anything else than fbx
    b) Unity converts the blender file to fbx first, then imports it as fbx.
    c) Unity does this conversion via blender (or other apps). If you don’t have blender installed on your pc, Unity can’t import blender files anymore.

  2. For Importing certain objects :

a) In Blender (or other apps) select the object you want to import into Unity.
b) Export Selected Object as FBX via Blender File Menu. Actually I didn’t use blender before but all 3D apps should have something called “Export Selected”.

In Blender, you can move the objects you want to hide from Unity into a separate collection and disable that collection by unticking its checkbox.

You can then import the .blend file directly and the hidden objects won’t show up in Unity.