GUI.Drawtexture - is there a faster way of rendering 2d to the screen?

Good evening all.

I’m making some good progress with my first 2d game in unity so far although I’ve noticed that it runs fairly slowly on android, i’m suspecting this is due to a maximum of ~ 50 draw calls being made per frame in the OnGUI section of code.

I’m currently using GUI.Drawtexture to display my sprites and was wandering if there’s a faster way. I’m using unity basic btw so I don’t think I can use those nifty Graphics.Blit and draw texture commands that are just out of reach of my budget.

Is there an alternative method possible to reduce te number of draw calls and speed up rendering? The game isn’t complex, it’s a basic space invaders clone?

How many draw calls should I be aiming for realistically?

thats a very slow method you’re using - probably the slowest possible method in unity for 2D.

The fastest method is to disable and remove all traces of gui (gui is horrible slow for mobile) and use quads - these are meshes which are made of 2 triangles each, and just throw them around with dynamic batching.

Thanks hippocoder, I had a feeling I was on the wrong path, although it’s proved handy for learning purposes (getting something on the screen using essentially plain code)

I managed to have a quick experiment with texture copying late last night using get and set pixels. Admittedly, I was still using a single GUI.DrawTexture call but it meant there was only 1 quad being rendered, with the texture being changed using get and setpixels, then clearing what i guess is essentially a faux rendertexture at the start of each frame.

I realise, after reading your post that it’s a different method but is it wotrh persuing? Either way I’ve learnt how to animate textures this way!

Thanks once again for your help.

Just checked out the FPS, wow, it sure does enjoy dropping either way! Definately going to try to do the textured quads approach instead now! This is possible to do all insdie code though I trust? I’m guessing I just create a new mesh, veticies, triangles, material and uv the co-ords for this yup?