Giter Site home page Giter Site logo

rihardn / blender-to-unity-fbx-exporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edyj/blender-to-unity-fbx-exporter

1.0 0.0 0.0 1.99 MB

FBX exporter addon for Blender compatible with Unity's coordinate and scaling system.

License: MIT License

Python 100.00%

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

Blender To Unity FBX Exporter

FBX exporter add-on for Blender 2.80+ compatible with Unity's coordinate and scaling system. Exported FBX files are imported into Unity with the correct rotations and scales.

How to install

  1. Clone the repository or download the add-on file blender-to-unity-fbx-exporter.py to your device.
  2. In Blender go to Edit > Preferences > Add-ons, then use the Install… button and use the File Browser to select the add-on file.
  3. Enable the add-on by checking the enable checkbox.

Blender To Unity FBX Exporter Add-On

How to use

File > Export > Unity FBX (.fbx)

Exports all Empty, Mesh and Armature objects in the current scene except those in excluded collections. The full hierarchy is properly preserved and exported, including local positions and rotations.

Blender To Unity FBX Exporter Menu

The File Browser exposes selection and armature options:

Blender To Unity FBX Exporter Options

How it works

The exporter modifies the objects in the Blender scene right before exporting the FBX file, then reverts the modifications afterwards.

Every object to be exported receives a rotation of +90 degrees around the X axis in their transform without actually modifying the visual pose of its geometry and children. This is done in the root objects, then recursively propagated to their children (as they inherit a -90 rotation after transforming their parent). The modified scene is then exported to FBX using Blender's built-in FBX exporter with the proper options applied. Finally the scene is restored to the state before the modifications.

When Unity imports the FBX file all objects receive a rotation of -90 degrees in the X axis to preserve their visual pose. As the objects in the FBX already have a rotation of X+90 then the undesired rotation is canceled and everything gets imported correctly.

Why not use the "Experimental - Apply Transform" option of the default FBX Exporter?

This option doesn't work with object hierarchies of more than 2 levels. Objects beyond the 2nd level keep receiving unwanted rotations and scalings when imported into Unity.

Why not import the .blend file directly in the Unity project?

Requires Blender to be installed in the system, so:

  • it's a no-go for publishing packages in the Asset Store.
  • .blend files don't work with Unity Cloud Build.

Known issues

  • Negative scaling is imported with a different but equivalent transform in Unity. Example: scale (-1, 1, 1) and no rotation is imported as scale (-1, -1, -1) and rotation (-180, 0, 0). In Unity this is equivalent, and may be changed to, the original scale (-1, 1, 1) and rotation (0, 0, 0).
  • Child objects in instanced collections receive an unneeded 90 degrees rotation in the X axis. Clearing this rotation in Unity gives the expected result. (#3)
  • Exporting right after deleting an object throws an exception. Workaround: select some object before exporting. (#17)

Tested and working:

  • Mixed EMPTY and MESH hierarchies with depth > 3.
  • Local rotations are preserved.
  • Non-uniform scaling.
  • Mesh modifiers.
  • Multi-user meshes and linked objects, with and without modifiers.
  • Armatures and Armature modifier.
  • Partial selections (Selected Objects Only).
  • Hidden objects and collections (eye icon in the outliner).
  • Disabled objects (monitor icon in the outliner). Imported with MeshRenderer disabled in Unity.
  • Disabled collections (monitor icon in the outliner).
  • Excluded collections (unchecked in the outliner). Won't be exported.
  • Nested collections.
  • Objects with their parent in a disabled/excluded collection.

About the author

Angel "Edy" Garcia
@VehiclePhysics
https://vehiclephysics.com

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

Contributors

edyj avatar

Stargazers

 avatar

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.