- Home /
Reduce Draw call for Multiple GUI Textures with same Texture
I have multiple GUI Textures with same texture in my game. It results large number of DrawCalls . How to reduce DrawCalls using common textures ?
Example code
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
public GUISkin MyGUISkin;
void OnGUI()
{
GUI.Box ( new Rect ( Screen.width*0.1f,Screen.height*0.12f,Screen.width*0.49f,Screen.height * 0.58f),"",MyGUISkin.customStyles[1]);
GUI.Box ( new Rect ( Screen.width*0.1f,Screen.height*0.22f,Screen.width *0.49f,Screen.height * 0.58f),"",MyGUISkin.customStyles[1]);
}
}
I notice that you keep bumping this question back to the top of the queue. Are you looking for something else you don't feel is answered?
Don't worry about DrawCalls in GUI system, 4th version is optimized well, so see to FPS not to drawcalls. I've made some tests: own sprite system VS OnGUI and found that CPU usages is the same, FPS the same. just small difference in GPU statistics. On this video http://youtu.be/1SmWcfDFgag there are 2 scenes, black background - 1 draw calls (planes and atlas), blue background OnGUI. (sorry for video quality it record desktop quite bad, and you can see not smooth movement of textures)
i use 4.2 version of Unity . In my project DrawCalls is 70. Is it work on mobile platforms.
sure, for example, here is my application which has about 70-100 drawcalls for GUI, and work the same as with own sprite system(similar to ngui or ex2d and so on) ][1]
just avoid to use Layout system, and cash all your position (Rect) values.
Answer by Eric5h5 · Oct 13, 2013 at 05:04 AM
You can't do that with OnGUI code. You'll have to use something else, like a third-party GUI system.
Third-party solutions like NGUI and EZGUI build their UI in world space and use Texture Atlases and a common material so that drawcalls batch. $$anonymous$$ore info:
http://answers.unity3d.com/questions/14578/whats-the-best-way-to-reduce-draw-calls.html