- Home /
How to deal with scale of imported models and scripting
Hi, Using C# I wrote a simple script that lowers a cube to terrain level, step on the trigger again and the cube "gate" raises. Works fine. However when I apply my script to an import model it doesnt work. I had a look at the scale seems way off. In the import settings for the model I set the scale to 1. Then when I create an instance of the model my Y scale is 0.2. But in world units its much bigger. I added a box collider to the model and used : gateHeight = transform.collider.bounds.size.y
and it looks like its giving the correct height. Is there a way to account for this? IE I want to scale the model 1:1 according to world units just like the default cube primitive so that I can apply my script to primitives and imported models alike? Thanks.
I suppose your model would then be 5 times higher than your standard Unity unit. Try changing your import options to scale it to 0.2 and then set the Scale of the gameObject to 1:1:1. I'm not certain of this though, so I'm posting this as a comment
Thanks. I did think of that but then that scale ratio could be different on each model. It would be handy if there were a generic approach to this. Or is it a case of getting the scale right in the modelling program to begin with?
in 3ds max 1 unity unit = 100 max units. that's the scale i work in. most 3ds apps like blender work the same way.
The way I work normally is to model some "bits n pieces" then assemble in unity. I might scale some things up and scale down others so getting the scale right initially may not happen. So what Im wondering is there any way of getting the actual dimensions of a model in the inspector? Cos it looks like the scale values in the inspector are multiplied by the import scale value and then multiplied by the actual dimensions. I had presumed that if I import a model at 1 scale then its actual scale would appear in the inspector. Sorry now if Im not explaining this clearly.
yeah i do the same thing,just when i model i stay observant of its size,
As for getting size of models in inspector, yes but it requires some scripting (basically search for each of the vertices an get the $$anonymous$$ and max of each axis and compare them) ,
but you can measure it with a cube. unity preset cube is 1x1x1 so scaling to a size of something else with give you its dimensions in the form of the cubes scale. unity also has grid you can use for measurement.
inspector scales always start at 1 for me. no idea how you got imported scale but all models (from 3ds max) are multiplies by 0.01 (1/100) to make them 100 times smaller so that the scaling matches. (i think 3ds max works in centimeters). but you can change it in the import settings, for consistency i leave it as a multiple of ten.