Which is a more optimized way of rotating an object?
- Rotate the object via script?
- Animate the object and import it in to unity / animate it inside Unity with the Animation View?
|
1
|
Which is a more optimized way of rotating an object?
|
|||
|
|
|
|
I tested this out and there seems to be very little difference. I tried making a rotating cube in two ways:
For both I tried spawning various amounts of them, with and without the MeshRenderer enabled. All objects were visible on the screen all the time.
As can be seen, using animation is slightly faster for high object counts. If all objects had not been visible on the screen all the time, the advantage of animations would be bigger, when the option is used to switch animations off when they're off-screen (new in Unity 2.6). This was tested on a Mac. I don't know if the same would apply to iPhone, but my bet would be that animations are still more efficient there. Note that this was tested inside the editor - in a real game all the fps'es would be higher, but these are good enough for the purpose of comparison. |
||||||||
|
|
|
If you don't cache the transform, every time you use "transform", what really happens is GetComponent( typeof(Transform) ) as Transform. I always cache my transforms because of this. Here's the video where I learned about this. I always use |
||
|
|
|
|
I expect the script would take very little memory, while the animation would take more than a little. |
||
|