Hi there
My main level requires 4 buttons on the screen…
My timer and score shows their values as custom drawn images…
Combined with the other textures on screen this gives me a total of 23 DrawTexture() calls.
I read somewhere that the GUI system is not optimized for the iPhone and should be avoided wherever possible but if absolutely needed, it should be limited to 2 or three instances.
I thought placing 23 calls in 1 OnGUI function meant it would be 1 instance but it seems 23 calls in 1 OnGUI counts as 23 instances… Ouch!
Now, during a recent support session here on the forum and some debugging, I found that my main menu crashes the iphone because i have 1 OnGUI call that makes 8 DrawTexture calls…
I am now actively trying to change those 23 textures to Gui textures but i have hit a snag…
Most of them can be converted without too much of a pain, but the progress indicators overlay a colored image on top of a single colored version of the same image. As far as I can see, GUITexture cannot clip images so this means my progress indicators will HAVE to be drawn using OnGUI so that is 3 instances already and maxes out my available OnGUI calls… but what about my 4 buttons? That is how the player selects what weapon to use. The way the game works, it is critical for the player to able to change their weapons as quickly as humanly possible so I have simply placed each of the 4 weapons on screen as a button so “tap and use”… Can’t get any faster than that!
Buttons… OnGUI… No more OnGUI calls left… Hmmm… [thinking]… hmmm…
GUITexture… GUITexture as a button???
This brings to mind the following question:
“How did people impliment on-screen buttons BEFORE the new GUI system?”
Can one use a GUITexture as a button?
I saw on the occlusion sample project that they test wether a player has hit a button by testing the screen coordinates of the touch.Is that the only (optimized) way to implement buttons on the iPhone?