Support => NGUI 3 Support => Topic started by: newnixon on April 25, 2012, 12:09:24 PM
Title: GUI interaction with game
Post by: newnixon on April 25, 2012, 12:09:24 PM
I have a project where I have an interior of a car and I want to show all the components of the car when you roll over them and as you go through I want ngui to keep track of where you have been. So is there a way that anyone knows how to make check boxes fill in as you click on game objects in your scene? An example would be that if you clicked on the radio it would fill in the one of the check boxes on my ngui panel.
Title: Re: GUI interaction with game
Post by: ArenMook on April 25, 2012, 02:37:54 PM
Add a script to your buttons that marks some checkbox in OnHover (true).
Title: Re: GUI interaction with game
Post by: newnixon on April 25, 2012, 03:35:19 PM
Thanks, but I was looking for code that would make the x in the check box mark as active once you click a game object in my scene.
Title: Re: GUI interaction with game
Post by: ArenMook on April 25, 2012, 06:14:36 PM
Script attached to a button:
usingUnityEngine;
publicclass MarkCheckboxOnClick : MonoBehaviour
{
public UICheckbox checkbox;
void OnClick ()
{
checkbox.isChecked=true;
}
}
Title: Re: GUI interaction with game
Post by: newnixon on April 26, 2012, 10:19:59 AM
Ok cool thanks!! I got it to work from a button but I can't get it to work from a game object. I have a box collider on a toggle switch inside a car that when I click it i want to make the check box, checked. I know it's simple but I can't seem to figure it out.
Title: Re: GUI interaction with game
Post by: ArenMook on April 26, 2012, 03:13:33 PM
Do you have a UICamera script on your main camera? Events won't be sent out without it.
Title: Re: GUI interaction with game
Post by: newnixon on April 26, 2012, 03:49:28 PM
Yep that was it!! Just added it works now. Thanks!!