How to Approach iPhone Menus GUI

So, like all games, I need a front menu with various sub-menus like high scores, options, credits, etc. Can someone give me advice about how to approach this on a high-level?

Where do I start? Do I set up separate scenes for each menu and flip between them?

What if I want a fade-in/fade-out effect between menus?

OO-wise, should I create individual objects for each GUI element in the menu?

Should I use UnityGUI or GUITextures? What’s the performance impact of UnityGUI vs GUITextures?

What about scrolling screens? How can I make my scrolls match up with the standard behaviors developed by Apple, like flicking?

How can I set up buttons and other elements to match Apple’s?

You could either stay and do it all in Unity, or you could make it in xcode and interface builder.

Unity Option:
I would definitely not do the whole menu with guiTextures/guiTexts. UnityGUI is SO much easier.

You should make the whole menu in one scene, and have a script like this:

private var menu = "highscores";
private var menuOpacity = 0.0; // Use this to fade the menu in and out.

function OnGUI () {
   GUI.color.a = menuOpacity;
   if (menu == "main") {
      // Draw the main menu here.
   }
   else if (menu == "highscores") {
      // Draw highscore stuff.
   }
   GUI.color.a = 1.0;
}

For scrolling, it’s not to hard to simulate apple’s scrolling with UnityGUI. Just use BeginGroup () and EndGroup () methods for cropping, and you will have to make some iPhoneTouch code to scroll.

Xcode Option:
You have to communicate back and forth from unity to xcode. One disadvantage to this method is that you can not make your game multi-platform because you are depending on xcode.

Thanks Daniel, those are some good tips. As much as I like Apple’s interface, I’m not keen on Xcode implementation because my objective C knowledge is too limited and I’d rather devote my full energies to the gameplay.

So you would do all menus in a single scene of their own? That’s interesting. Is that how most folks on here approach it?

I’ve read a few debates about using UnityGUI vs GUITextures, can someone give me a sense of what performance implications this has. I imagine I can get away with quite a bit of non-efficient coding before it becomes noticeable in a menu, right?

What about the pause menu? Is that usually handled in a separate scene from the main game? After all, I want to keep all my game states close by in case the user unpauses.

Yes, I’m sure it its. I don’t see any advantages of splitting a menu into separate scenes. Am I missing something?

Yes, I’ve never had an issue with performance and UnityGUI. Unless you have a ridiculous amount of gui on-screen, you have nothing to worry about. Plus it’s just a menu, so who cares about performance? And also you can set useGUILayout = false; to gain a 50% performance boost with UnityGUI.

No, the pause menu should definatly be in the same scene. Just set Time.timeScale = 0.0; then just overlay the menu when you want to pause.

Thanks, Dan! Great stuff.

What is the difference between using BeginGroup and ScrollView for scrolling menus. I want to have browser-like slider to show the user’s vertical location within the menu, but I also want to use to just be able to flick up and down to scroll.

BeginGroup() will just crop some GUI, without any scrollbars. BeginScrollView() will do the same thing, except it has the ability to display scrollbars as well.

Look at getting Easy GUI, there is a discussion on the iPhone forum about it.

Look at getting Easy GUI, there a discussion on the iPhone forum about it.