Customizing the GUI
While it is great that Unity provides us with all of this functionality to save us time in creating elements, the actual aesthetics leaves a little to be desired. Thankfully, UnityGUI allows us to customize the appearance of our controls by making use of GUIStyle
, which is an optional third parameter to our control functions. If we do not specify a GUIStyle
parameter, Unity's default will be used, which is what we experienced last time. This can work fine while testing something out. However, since we're trying to create a polished and complete project, we're going to create one of our own by performing the following steps:
- Open up the
MainMenuGUI
script file and modify the function to accommodate the changes in bold:using UnityEngine; using System.Collections; public class MainMenuGUI : MonoBehaviour { public int buttonWidth = 100; public int buttonHeight = 30; public GUIStyle titleStyle; public GUIStyle buttonStyle; void OnGUI() { ...