Unity Manual User Guide Creating Gameplay Game Interface Elements

Game Interface Elements

To create interface elements for your game, you have some options to choose from. You can use GUI Text and GUI Texture objects, or you can use UnityGUI. UnityGUI is the Interface Scripting system introduced in Unity 2.0. The rest of this page contains a detailed guide for getting up and running with UnityGUI.

GUI Scripting Guide


GUI stands for Graphical User Interface. Unity's GUI system is called UnityGUI. UnityGUI allows you to create a huge variety of GUIs complete with functionality very quickly and easily. Rather than creating a GUI object, manually positioning it, and then writing a script that handles its functionality, you do all of this at once in a small amount of code. This works by creating GUI Controls, which are instantiated, positioned, and defined all at once. For example, the following code will create a fully functional button from scratch: function OnGUI () { if (GUI.Button (Rect (10,10,150,100), „I am a button”)) { print („You clicked the button!”); } }


This is the button created by the code above Although this example is very simple, there are very powerful and complex techniques available for use in UnityGUI. It is a broad subject, and the following sections will help you get up to speed as quickly as possible. This guide can be read straight through, or used as reference material.

[[unity_manual:http://unity3d.com/support/documentation/components/gui-basics|UnityGUI Basics]]

This section covers the important concepts of UnityGUI, giving you an overview as well as a bunch of working examples you can paste into your own projects. UnityGUI is very friendly to play with, so this is a good place to get started.


This section lists every available Control in UnityGUI. It is complete with code examples and images.


Creating functional GUI controls would not be as useful if their appearances couldn't be customized. Thankfully, we've thought of this. All controls in UnityGUI can be customized with GUIStyles and GUISkins. This section explains how to use them.

[[unity_manual:http://unity3d.com/support/documentation/components/gui-layout|Layout Modes]]

UnityGUI features two ways to arrange your GUIs. You can manually place each control on the screen, or you can use an Automatic Layout system which works a lot like HTML tables. Using one system or the other is as simple as using a different class, and you can mix the two together. This section explains the functional differences between the two systems, including examples.

[[unity_manual:http://unity3d.com/support/documentation/components/gui-extending|Extending UnityGUI]]

UnityGUI is very easy to extend with new Control types. This chapter shows you how to make simple compound controls - complete with integration into Unity's event system.

[[unity_manual:http://unity3d.com/support/documentation/components/gui-extendingeditor|Extending Unity Editor]]

The main Unity editor is written using UnityGUI. It is completely extensible using the same code as you would use for in-game GUI. In addition, there are a bunch of Editor specific GUI widgets to help you out when creating custom editor GUI. Previous Next

unity_manual/game_interface_elements.txt · ostatnio zmienione: 2012/09/30 11:39 (edycja zewnętrzna)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki