- Home /
Question by
ronronmx · Nov 15, 2011 at 06:50 AM ·
importfbxassetpostprocessor
How to auto rotate object on FBX import?
I am currently using the 'AssetPostprocessor' to change some of the FBX import settings automatically when importing objects. I also want to 'Auto Rotate' imported objects on the Y axis by 180 degrees, so that I don't have to manually do it post-import.
How can I achieve this? Thanks for your time! Stephane
Comment
Best Answer
Answer by Rod-Green · Nov 15, 2011 at 10:32 AM
This will do it.. HOWEVER this probably isn't the right way to do it - Please read below.
using UnityEngine;
using UnityEditor;
using System.Collections;
public class FBXPostProcess : AssetPostprocessor
{
void OnPostprocessModel (GameObject g)
{
if(assetPath.EndsWith(".fbx"))
Apply(g.transform);
}
void Apply (Transform transform)
{
transform.Rotate(new Vector3(0.0f, 180.0f, 0.0f));
}
}
Honestly I would suggest creating a script in you're tool that rotates 180 and bakes the transform before export.. like this one for Maya:
$selection = ls("-selection");
setAttr ".rotateY" 180;
makeIdentity -apply true -t 0 -r 1 -s 0 -n 0;
file -force -options "v=0" -typ "FBX export" -pr -es "C:/testModel.fbx";
undo;
undo;
select($selection);
Thanks a lot for the answer! And you're right, I should probably rotate my objects on export like you said. Either way thanks for both examples!