Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity Game Development Essentials

You're reading from  Unity Game Development Essentials

Product type Book
Published in Oct 2009
Publisher Packt
ISBN-13 9781847198181
Pages 316 pages
Edition 1st Edition
Languages
Author (1):
Will Goldstone Will Goldstone
Profile icon Will Goldstone

Creating the menu — approach 1


In this first approach, we'll create a menu that uses a transparent background texture as a GUI Texture, in the same way as we have just done with our main title logo.

We will then need to write a script in order to make the texture receive mouse events for mouse enter, mouse exit, and mouse down/up.

Adding the play button

In the Menu folder in the Project panel, select the texture called PlayBtn. Go to GameObject | Create Other | GUI Texture. Select the PlayBtn object in the Hierarchy that you have just made. In the Inspector, set its Transform position to (0.5, 0.6, 0.

GUI Texture button script

This is the first of our three buttons, and because they all have common functions, we will now write a script that can be used on all of the three buttons, using public member variables to adjust settings. For example, each button will:

  • Play a sound when clicked on

  • Load a different level (or Scene in Unity terms) when clicked on

  • Swap texture when the mouse is over them...

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}