Hi there I find it surprising that there is nothing on google related to a tab-style user interface. Can anybody maybe steer me into a direction? Thans
A tabbed interface in unity would really just be a bunch of GUI Buttons, that activated different GUI Labels in a set area; I'd probably use an enum for that part.
Do you think it could work to have 3 groups next to each other and have boolean variables control which one is visible?
The enum is probably better because it can have only one state at a time. Imagine a character sheet with "Inventory", "Skills", and "Quests" all together. With bools, you might have to toggle them back and forth and have the right one. With an enum, set the "Page = Pages.Skills" and use that enum to show *only* the right page instead of risking having no page set to true or multiple pages set to true.
The same principle is used here and needs little modification to give you your tabs in stead of menu screens: http://angryant.com/2010/03/15/building-a-menu-of-delegates-and-enums/
Made one for editor GUI, looks almost like the Unity tabs: Code (CSharp): /// <summary> /// Creates tabs from buttons, with their bottom edge removed by the magic of Haxx /// </summary> /// <remarks> /// The line will be misplaced if other elements is drawn before this /// </remarks> /// <returns>Selected tab</returns> public static int Tabs(string[] options, int selected) { const float DarkGray = 0.4f; const float LightGray = 0.9f; const float StartSpace = 10; GUILayout.Space(StartSpace); Color storeColor = GUI.backgroundColor; Color highlightCol = new Color(LightGray, LightGray, LightGray); Color bgCol = new Color(DarkGray, DarkGray, DarkGray); GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.padding.bottom = 8; GUILayout.BeginHorizontal(); { //Create a row of buttons for (int i = 0; i < options.Length; ++i) { GUI.backgroundColor = i == selected ? highlightCol : bgCol; if (GUILayout.Button(options[i], buttonStyle)) { selected = i; //Tab click } } } GUILayout.EndHorizontal(); //Restore color GUI.backgroundColor = storeColor; //Draw a line over the bottom part of the buttons (ugly haxx) var texture = new Texture2D(1, 1); texture.SetPixel(0, 0, highlightCol); texture.Apply(); GUI.DrawTexture(new Rect(0, buttonStyle.lineHeight + buttonStyle.border.top + buttonStyle.margin.top + StartSpace, Screen.width, 4),texture); return selected; }