Why is Transform.localScale Slow

I’m a bit confused with the performance of localScale.

I have about 50 planes in my scene whose Transform is updated every Update. Everything works fine if I just change the position, eulerAngles or whatever. But if I add a line changing the localScale the framerate slows down from 60 FPS to 15 FPS, even if it is always the same scale.

Label.transform.localScale = new Vector3 ( 3, 3, 3 );

It doesn’t matter if I run it in the WebPlayer or Standalone mode. Anyone has an idea? Could there be a workaround, like setting the worldMatrix directly?

There’s this other unresolved thread with a similar topic regarding Android Transformlocalscale Very Slow and another unresolved thread
Does ransformlocalscale now use gpu.

glad to know that the new moderation features are working. when somebody approves this crap, they should get THEIR account suspended along with the spammer imo.

Sorry about that, that guy was suspended, but apparently whomever was cleaning things up didn't see this comment. If you notice any more, please let us know!

1 Answer

1

I did find the solution to it. The slowdown issue is not the GameObject itself which I want to rescale, but its collider. Even if never using the collider, it is actually there and will be updated with a call to transform.localScale resulting in a more complex scaling.

The collider is used for physics and collision detection, which is needed in my case, the solution is quite simple - destroy the collider of your GameObject.

GameObject.Destroy ( myGameObjectrenderer.collider );

Happy Scaling!

Or just never have a collider component on your gameObject in the first place? You should never have to just delete this stuff at runtime, if you can get rid of it in the editor.