Optimization of multiple mesh instances

Hello.
I have a lot of instances of same mesh on scene, which are rotating constantly and synchronously. I found in profiler that applying rotation to each instance significantly decreasing app performance. How can this be optimized? Is there any way to share a mesh between multiple objects, without copying it? Or can I somehow render mesh in multiple positions during one render loop?

Solved by using Graphics.DrawMesh instead of having separate GameObject for each mesh, as mentioned in aldonaletto’s second comment

If the meshes have colliders, you must add kinematic rigidbodies to them - this helps the collision system to update quickly. Additionally, the rotation could be calculated only once and used for all meshes - like this:

//Script CalcRotation.js, attached to any object in scene:

public var rotSpeed: float = 180; // rotate at 180 degrees per second
static var rot: Quaternion; // rotation common to all meshes

function Update(){
  // rotate about Y at rotSpeed:
  rot *= Quaternion.Euler(0, rotSpeed * Time.deltaTime, 0);
}

In the mesh script, just assign the common rotation to the object:

function LateUpdate(){
  transform.rotation = CalcRotation.rot;
}

LateUpdate is used instead of Update in order to keep the meshes in sync. If Update is used, the execution order must ensure that CalcRotation is executed first.

Do they need to be individual rotations or individual game objects - is it critical?

If not, you should animate them in modeling package, it’s much cheaper. Instance of the same mesh doesn’t matter, it’s still a separate calculation.

If they are critical, you could optimize further by:

a) lowering the calculation to 24 calculations per second. 24fps is movie frequency… u could go lower but it will look more choppy. Better than crappy framerate perhaps.

b) see which objects that are being displayed on screen and only calculate those… since you’re probably using deltaTime to see when the last calculation occurred, the rotation won’t look off when new rotating objects come into view/leave view. of course, if their rotation could interact with offscreen things, this won’t work. It will also have some smallish overhead to see if it’s being rendered or not.

c) Make sure the instance is dynamically batched whenever possible. IOS devices really can’t take a lot of drawcalls at all…like 50-150 from what I’ve read… even PS3 can only handle 2000. (see Unity - Manual: Draw call batching)

If all else fails, find the best way to fake it… that’s what games are mostly aren’t they… lot of great magic.

Thank you both aldonaletto and SinisterRainbow. Yours comments really help me