How can I do basic sprite rendering (render_sprite(pos, rotation, scale)) within a script?

Hi,
I’m fairly new to Unity, and I’ve been having a lot of issues performing simple rendering tasks. I’ve been wanting to render a sprite many times with increasing rotation to form a circle. Here’s a crummy diagram to explain my goal:

The basic trig to get the positions and rotations is not a problem at all - the problem is I don’t know how to do the basic render calls to draw the sprites. Looking through the manual, it seems I am expected to create new Sprite objects for each and every sprite around the circle - but if I’m drawing a lot of circles like this with high precision, this could be many thousands of individual objects when it would be a lot easier to manage a bunch of simple render calls in a row.

There’s one possible option I can take - manually creating the vertices of a the full circle with texture coordinates and set up indices and pass them into a MeshFilter (I think). But it seems like a lot more effort than it should take to simply render a bunch of simple rotated and scaled sprites.

Is there any simple ‘render sprite’ draw call that I can place in a script in a draw event, like
render_sprite(texture, x, y, xscale, yscale, rotation)?

Sprites are specifically SpriteRenderer components attached to GameObjects; they can’t be rendered using any other technique. For immediate mode rendering, Graphics.DrawMesh exists. For performance reasons, though, you should really create a single mesh with all the quads placed appropriately. Dynamic batching is an option that exists, but it still takes time, and creating a mesh with all vertices already computed up front bypasses all that.

–Eric

this maybe helpful

Ok, thanks for the responses! I might go about making a script to attach to an object with a DrawMesh component and give helper functionality to modify the vertices in a friendlier manner. I need to be able to modify things like the circle’s radius and precision on the fly, so unfortunately I can’t pre-compute the mesh on init.

Cheers.

I would still recommend using a standard mesh. There aren’t any issues with modifying the radius and precision on the fly, and it will render faster as mentioned.

–Eric