Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity for Architectural Visualization

You're reading from  Unity for Architectural Visualization

Product type Book
Published in Sep 2013
Publisher Packt
ISBN-13 9781783559060
Pages 144 pages
Edition 1st Edition
Languages
Author (1):
Stefan Boeykens Stefan Boeykens
Profile icon Stefan Boeykens

Basic heads-up-display with a custom GUI


When we explained the use of GUIText and GUITexture components in Chapter 4, Promenade Architecturale, they were static. This is fine for a fixed logo, but not when you need dynamic information. You can script these components, but they are not the most efficient ones to use. This is shown in the following code:

public Texture2D someTexture;
...
guiText.text = "Hello";
guiTexture.texture = someTexture;

An alternative is the use of the Unity Graphical User Interface (GUI) classes. To display a GUI inside a script in Unity, use the OnGUI() event. This runs independently of the regular Update() cycle. Inside this event, you can display buttons, text labels, sliders, panels, scroll areas, textures, and toggle switches.

We illustrate this with a simple GUI script that displays the name of the trigger we enter, as shown in the following screenshot, which also displays some feedback in the console.

The following steps will show how to set up a simple scene...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}