Skip to Content
Mastering UI Development with Unity
book

Mastering UI Development with Unity

by Dr. Ashley Godbold
April 2018
Beginner content levelBeginner
468 pages
11h 7m
English
Packt Publishing
Content preview from Mastering UI Development with Unity

GetButton

If you have a button defined as an axis in the Input Manager, you can use GetButton(), GetButtonDown(), and GetButtonUp() to determine when a button has been pressed.

GetButton() returns true while the button is being held, GetButtonDown() returns true only once, on the frame that the button is initially pressed, and GetButtonUp() returns true only once, on the frame that the button is released.

Within each of the functions, you place the axis name from the Input Manager within the parentheses within quotes. These functions should be checked in the Update() function of a script so that they are continuously being checked for.

So, for example, if you wanted to check whether the Enter key is being pressed since it is assigned to a ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Game Development with Unity for .NET Developers

Game Development with Unity for .NET Developers

Jiadong Chen
Unity UI Cookbook

Unity UI Cookbook

Francesco Sapio

Publisher Resources

ISBN: 9781787125520Supplemental Content