Coder Social home page Coder Social logo

blender-to-unity-fbx-exporter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blender-to-unity-fbx-exporter's Issues

Improvement(?)

Thank you very much for this addon, it really makes with importing Blender models into Unity a lot easier!

While all the individual object's positions and rotations are correct, it seems like I still need to rotate the whole model by 180° on the Y-axis in Unity to make it face in the right direction.

So I tried making a fix for it (the comments in the code should hopefully be self explanatory, although I am not 100% sure about why some of my code segments seem to be required for it to work correctly).
Maybe there is a better way, but this seems to work in all scenarios I tested (including more than one child object).

This is the code starting from line 130.
I have also attached the full file below (although as .txt, as .py files are not supported for uploading in this case):

# Reset parent's inverse so we can work with local transform directly
		reset_parent_inverse(ob)

		# Create a copy of the local matrix and set a X-90/Z-180 matrix
		mat_original = ob.matrix_local.copy()		
		
		rot_x = mathutils.Matrix.Rotation(math.radians(-90.0), 4, 'X')
		rot_z = mathutils.Matrix.Rotation(math.radians(-180.0), 4, 'Z')
		
		ob.matrix_local = rot_x @ rot_z	
		
		# Apply the rotation to the object
		apply_rotation(ob)
		
		if (ob.parent):
			# Reapply the previous local transform with an X+90 and Y+180 rotation
			ob.matrix_local = mat_original @ mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X') @ mathutils.Matrix.Rotation(math.radians(180.0), 4, 'Y')
		else:
			# Reapply the previous local transform with only an X+90 rotation
			ob.matrix_local = mat_original @ mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X')
			
			# Correct position by inverting X and Y values
			loc_or = ob.location		
			ob.location = (-loc_or.x, -loc_or.y, loc_or.z)
			
			# Correct rotation by inverting Y value
			rot_or = ob.rotation_euler
			ob.rotation_euler = (rot_or.x, -rot_or.y, rot_or.z)

Hope this helps and of course please let me know if you have any suggestions or if there might be a better way!

blender-to-unity-fbx-exporter.txt

Rotation problem?

image
here is the pic that face to -y in blender.
and when export to unity ,it will face to oppsite direction like this
image

Wheel location transform and full FBX rotated while rotation value is 0

Trying to use the cars from the Transportation add-on for Blender in Unity with the Edy's Vehicle Physics. Though, when i use this Blender-to-Unity-FBX-exporter is get the following strange behaviour, on any car i try to export to Unity.

  • The wheels location get's transformed outside the vehicles.
  • The full FBX model is rotated itself, though the rotation value is 0.

The versions of Blender and Unity I'm using:

  • Blender 2.83
  • Unity 2020.3.0f1

See screenshots for an instant understanding of the problem.

Here you see the vehicle after importing it into Unity:
merc1

Here is the vehicle from Transportation add-on in Blender, all fresh no edits made:
merc2

I've tried to follow the instructions provided in the Readme of this git, though, i can't get it working. With the rotation I noticed the Wheelcolliders from the Vehicle Physics add-on are not working on the road..

Add Tangent Space when exporting FBX

In order to be feature complete with the Unity fbx importer the exporter should include a default option to include tangent space for those features that would required it.

Looping animations does not function

Hi!

When exporting a humanoid with bones and animations into unity and ticking the "loop time" checkbox in the unity import settings the animation will not loop for me (the animation still only plays once). The loop works when I make a standard exported fbx but it does not work when I use your script nor if I use the experimental "apply transform" setting when exporting a standard fbx. Is this a known issue? I really love your script and would so like to be able to fix this issue. Please say if you need example files from me.

Unable to export after deleting an object.

I've encountered an exception when trying to export the scene right after removing one of the objects.

How to reproduce:
1) Open an empty blender scene
2) In object mode add two Cube objects.
3) Remove one.
4) Try to export without selecting any object. (File > Export > Unity FBX)

Throws an exception "context is incorrect".

Screenshot - https://i.imgur.com/teWwMKt.png
I'm using Blender version 2.90.1

Path mode and embedded textures

I've been testing out your exporter and it's working great for me in 2.82a. Meshes, armatures and animations seem to export properly. The only problem is textures are not embedded, instead using relative paths.

I would fix this using the standard FBX exporter by setting Path Mode to Copy and the Embed Textures toggle as shown:
image

Of the features in the standard exporter, I use this one most often. Do you have any plans to adopt it? Thanks.

Wrong Rotation when exported object has "Fake User" enabled.

When exporting, my model had a +90 degree rotation on the X-axis, but in Unity, it was zeroed. After messing around, I found that the "Fake User" option was causing the problem. After disabling it, the rotation was fixed.

I don't know if this is intended or not, but just wanted to point it out. I also tried to reproduce it in a new file and it still happened.

I'm using Blender 3.3.1

Feature Request: overwrite file prompt and export profile dropdown

I've noticed that there's not prompt if you want to overwrite a file.
while usually annoying it is a necessary safety feature in my opinion.
it would be good to have because not everybody makes backups.
but it also wouldn't be the first time those prompts have been haphazardly skipped either.

also, a drop down where you can save export profiles for different scenarios like the default exporter has would be appreciated.
while the export options are limited, having a drop down saves just those few clicks.
not entirely necessary but completely awesome to have!

Exported objects are too big.

It seems that the exported objects when placed at the scale of 100, 100, 100 explicitly on the mesh entry itself render too big in Unity after exported.

Custom properties lost

Hi, i think it wold be amazing if theres an option to export custom properties, they are getting lost in the way.

thanks!!
Cris

For custom pose to work in Unity, have to export the model in a very specific way

Just adding a weird behavior that I noticed, tested with the same model from issue #14.

For the tail bones to appear with a custom pose in Unity, I have to export the model in Blender in a very specific way:
It seems I have to FIRST select the armature, THEN the 3D object, then export (using any export options).

That was the only way that worked, for the tail bones to be positioned correctly in Unity, with the custom curved pose.
Else (like if I selected the 3D object first, then the armature), the tail appears in a different pose, the "default pose" of the tail bones.

I don't know if that's intended, or if it's a bug with the exporter.

objects exports with wrong rotation

Object in blender at rotation 0,0,0 is facing -Y with +X to it's left.
When imported to unity, object at rotation 0,0,0 is facing +Z with -X to it's left. (rotation difference of 180 degrees on the up-axis)

The object in blender has position/rotation/scale all applied so they're at 0,0,0 for pos/rot and 1,1,1 for scale

Painted texture gets reset

I often forget to press Alt+S to save the current texture I'm painting. So it's very disheartening when the exporter just resets the texture to its currently saved state right after exporting.

Blender 2.83 quits after exporting.

Hi,

I am trying your exporter, but it crashes with my model. At the end I get an segmentation fault.

`FBX export prepare: Wrapping Objects...
Done (0.015395 sec)

FBX export prepare: Wrapping Data (lamps, cameras, empties)...
Done (0.000637 sec)

FBX export prepare: Wrapping Meshes...
Done (0.002220 sec)

FBX export prepare: Wrapping ShapeKeys...
Done (0.000052 sec)

FBX export prepare: Wrapping Armatures...
Done (0.000227 sec)

FBX export prepare: Wrapping World...
Done (0.000081 sec)

FBX export prepare: Wrapping Materials...
Done (0.001132 sec)

FBX export prepare: Wrapping Textures...
Done (0.000772 sec)

FBX export prepare: Wrapping Animations...
Done (0.000346 sec)

FBX export prepare: Generating templates...
Done (0.000075 sec)

FBX export prepare: Generating Connections...
Done (0.005486 sec)

FBX export fetch empties (31)...
Done (0.000445 sec)

FBX export fetch lamps (0)...
Done (0.000020 sec)

FBX export fetch cameras (0)...
Done (0.000037 sec)

FBX export fetch meshes (201)...
Done (0.759288 sec)

FBX export fetch objects (326)...
Done (0.059263 sec)

FBX export fetch remaining...
Done (0.001688 sec)

FBX export fetch animations...
Done (0.000027 sec)

export finished in 0.9175 sec.
Writing: /tmp/Lider.crash.txt
Segmentation fault (core dumped)
`

This is on Blender 2.83.

The writing of the file seems to work, but after that Blender just quits.

Remove Armature bone and export animations options

Would be nice to have 2 options:

  • Remove Armature bone - removes that extra bone created by Blender on export.
    That issue has been there for eternity without being addressed officially, tho there's only one addon that does that.

  • Bake animations - base feature of the default exporter

Use a base fbx file to determine what settings to export the updated fbx file in blender.

I have a problem where I am working on an VRChat avatar that I just so happened to have downloaded and worked on some customizations to it to:

  • Optimized it by merging some meshes (using Cats)
  • Optimized the material slots to be more helpful by merging similar ones together and reusing them.
    • Example is black, boots, & (Hair, Hair 1, & Hair 2)
  • Armatures:
    • Example is that when I do not want to use the blender provided armatures, but the unity ones due to DPS (Deep Penetration Bones) and I want to preserve them. Also it seems that blender adds extra end bones than what the unity ones add.

Due to the above, it would be great if I could then tell the exporter "Use the original fbx file that will be overwritten on export to provide the very options that I need for the export." Also simple mesh merging should not require armature changes?

Not working with armature.

Thank you for this tool! It does work on generic meshes but not in objects with armatures.
Attached is a simple scene with suzanne and a bone. The rotation still has to be -90 inside unity for a correct pose.
suzanne.zip

Exporting collection with Empties gives Runtime error

I'm not familiar with Blender but when testing this addon I noticed exporting collection that contains Empty objects results in a error:

Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 2.90\2.90\scripts\modules\bpy\ops.py", line 201, in call
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect

location: :-1

Just selecting the mesh objects and using Selected Objects Only works but the rotations are not correct. Is there a way around this or is the solution just not to use empty objects? Thanks.

Leaf bone option

thanks for the exporter! I've noticed it creates and exports unnecessary "_end" bones, the equivalent of turning on "Add leaf bones" in the regular fbx exporter, could this be added as an option?

Simply not working

After clicking the Export Unity FBX button the window is closed but no file has been create, not even an empty one.

Add-on doesn't install

I tried two different downloads: One of only the .py file and a second of the whole .zip.
When the first did not install, I tried the second.
Edit > Pref > Addons > Install seemed to proceed normally, even with a message at the bottom saying it was loading.
I see no error message. The Addon is not in the list. Search for "fbx" only shows the default Blender FBX exporter.
Do I need to disable that one, perhaps? Can they co-exist?
Am I doing something wrong?

Blendshapes Removed during export

As the title suggests, if a model is exported without any armatures but with blendshape data the resulting export will have removed the blendshape data from the mesh.

Blender 2.90 / 2.83 - Doesn't show up in addons list

I tryed to install the addon as described on the front page, the console tells me it has been installed.
It got copyed indeed but i can't activate it, since its not showing up inside blender in the add-ons tab

Feature idea: hierarchy empty objects

It would be great if Blender collections translated to empty object in Unity, cloning the exact same hierarchy from Blender to Unity: we would avoid reorganizing once again the objects in Unity. I don't know if such feature is possible to add, but I try to ask for it anyway.
Great job so far, keep going!

Armature not affecting model

When I use this importer, my model is no longer being influenced by the armature in Unity. When I try to play the animations in the model import settings, nothing happens. This is not the case when I export as .fbx the normal way, or when I save as .blend. I've tried toggling some of the options in the export window but nothing has fixed this. Am I missing something or is this not currently working?

EDIT: I should add that the armature is still animating it just isn't affecting the model.

Spline IK constraint not being exported correctly

My character has a tail bone chain. In one of the bones I apply a Spline IK constraint, linked to a Bezier curve.
The character armature is exporting correctly to Unity, except for the last bones of her tail.
I'm guessing it's an issue with the Spline IK constraint applied to the bone.

Tested with Blender 2.90.1, Unity 2020.2.0b5

I attached the Blender project used in this test:
tail-splineIK-issue.zip

The character armature in Blender: (notice the tail)
capture_20201015_001459_001_crop

The exported result in Unity: (tail bends weirdly at the end)
capture_20201015_001537_003_crop

The bone's Spline IK constraint properties: (the last bone, the tip of the tail, isn't part of the Spline IK chain)
capture_20201015_001831_004

Scaling issue with rigged character

I have a rigged character I'm trying to get published to asset store. When I export FBX the rig (I think) it is being scaled up by 100 so in Unity when character is animated, things don't go so well.

Without using this exporter, character moves correctly but rigging is -89.98 on X and scale is 100,100,100. All the body meshes have correct 1,1,1 scale.

My goal is to have it pass the "Fix Orientation" issue in the Unity Package Validator.

image

Blender 2.91 with Unity 2018.4, have also tried with U2019.4 (similar result)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.