Import settings

Why do my models always appear in unity at 0.01 scale when I import them as assets? from what I have read its better to avoid scaling meshes in unity, but by default all my meshes import at 0.01. why is this?

We solve this issue with an Editor script:

using UnityEditor;

public class FBXScaleFix : AssetPostprocessor
{
    public void OnPreprocessModel()
    {
        ModelImporter modelImporter = (ModelImporter) assetImporter;                    
        modelImporter.globalScale = 1;          
    }   
}

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

The above script is broken in Unity 5 which has a ‘filescale’ attribute along with ‘globalscale’. Now the filescale is 0.01 and read-only. Which sucks.

So I did manage to solve this, although not in Unity.

The problem is that the old FBX format that Blender 6.1 exporter writes to had its standard units in centimeters while Unity uses meters. In Maya for instance you could set it to use meters instead, but in Blender you can’t.


To fix it, I edited Blender’s fbx exporter script:

Find the file ‘export_fbx.py’ which for a standard Blender 2.73 installation should be in “C:\Program Files\Blender Foundation\Blender\2.73\scripts\addons\io_scene_fbx” and open it with a text editor.

Inside the file find the following block of code:

GlobalSettings:  {
		Version: 1000
		Properties60:  {
			Property: "UpAxis", "int", "",1
			Property: "UpAxisSign", "int", "",1
			Property: "FrontAxis", "int", "",2
			Property: "FrontAxisSign", "int", "",1
			Property: "CoordAxis", "int", "",0
			Property: "CoordAxisSign", "int", "",1
			Property: "UnitScaleFactor", "double", "",1
		}

Now edit the last property, ‘UnitScaleFactor’ and set it to ‘100’ instead of ‘1’ (because 100cm is 1 meter).

            Property: "UnitScaleFactor", "double", "",100

Save the file. You may have to make sure you have write access to it before you can do so.

Reopen Blender. Any new file you export as FBX6.1 should arrive in Unity with a FileScale of 1.0.

You can set the import scale in the import settings as well as other settings like calculate normals etc. When you then apply these settings the model will be reimported.

These settings are done on a per model basis. Select your model in the project view and you can change these in the inspector. Right click and select Import Settings in Unity iPhone.

The default import scale is 0.01 and i don't think this can be globally altered (although I've never looked at the default import settings work fine for me).

All of this is Unnecessary.
When working in Maya I figured out to work in Meters as I always do, Then when exporting set the scale factor to centimeters, and after importing it to Unity, set the scale factor of the imported object back to 1 and it solved it.

So sorry to bump this, but I need some related help, and didn’t think I should create a whole other topic.

Herman posted a C# script that seems to do exactly what I need. I bought some Unity package files containing lots of .fbx meshes fully textured and ready to go. However I am having the same problem of everything importing at a 0.01 scale. I am not a coder at all, so here is where I’m stuck.

The few times I use scripts, I use java. So I know to put a .js extension to my script. I don’t work with C/C# at all. I did some searching and found some posts say that C# uses the “.cs” extension. When I made a text file, and copied the text Herman posted, and saved as a .cs file, placed into my Editor folder, it doesn’t do anything. This leads me to believe I am messing up.

Could someone please tell me what extension to use, and if there is a specific file name I should use? For example I just called it “fbxscale.cs” Also should I re-import my unity package files? Or will it update them once I place this script in my editor folder?

Thanks for the help!

-Angelus