Gocy015
Gocy015

Reputation: 218

How to change a unity UI Button's state in code?

I'm now using unity 4.6,the new UI system , since i won't use mouse to control my game,could anyone tell me how can i change a button's state in script ?

Upvotes: 1

Views: 6802

Answers (1)

Kevin
Kevin

Reputation: 11

I would recommend you to start by trying to make your system work with keyboard, using the UI navigation system.

http://docs.unity3d.com/Manual/script-SelectableNavigation.html

You could manually set a button to selected state by using EventSystem.Current.SetCurrentlySelectedGameobject(yourGameObject);

If this button has an onLeft/OnRight etc. value setted, you will be able to interact with it with input Horizontal vertical axis, and to press it with a "Submit" value in input manager.

Once you're happy with it, you should try to catch your kinnect gestures and use them to send correct events I guess.

Upvotes: 1

Related Questions