OnGUI function and GUITexture components

Often have I read on several threads on this forum or on other websites that the OnGUI function was to be forgotten (as much as possible) when it comes to mobile applications.
Even though there are many voices on this forum I consider very trustful, I decided to run some tests, to measure and quantify the impact it has.
So I built a GUI using OnGUI functions (GUILayout, BeginArea, BeginGroup, DrawTexture, etc.) and I did the same interface using GUITexture. The result is… nothing : the number of draw calls is exactly the same between the two versions… I did the same with a GUITexture and a GUIText versus a GUI.Label and a GUI.DrawTexture.

What does it mean ?
A- I’m a master of the OnGUI function and I know how to optimise it like no one else does (I seriously doubt that)
B- I don’t know anything about how to use GUITexture and I’m so bad even the OnGUI function is not worse (I kind of doubt that too)
C- A little bit of both (Not much better of a solution)
So I would go with :
D- Something else I would really appreciate to get explanations about and possibly examples of a “real” optimisation and performance gain between the two solutions.

Thanks a lot.

Draw calls aren’t the only measure of performance by any means. With OnGUI functions, everything you do has to be recalculated every frame. So if you did this, for example:

function OnGUI () {
   GUI.Label(Rect(10, 10, 200, 30), score.ToString());
}

Then it has be updated at least once per frame. So you have a string conversion being done over and over again. Realistically, in most games that have a score, it stays the same 99% of the time, and only needs to be updated when it actually changes. So you can use a GUIText instead, and do this:

function UpdateScore (addToScore : int) {
    score += addToScore;
    guiText.text = score.ToString();
}

In that case you can call the UpdateScore function only when needed, and the rest of the time, the GUIText takes up no resources (aside from a draw call).

–Eric

Hmm , very good break down / explanation. Gave me some insight, thank you sir!