Author Topic: GUI interaction with game  (Read 5347 times)

newnixon

  • Guest
GUI interaction with game
« 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.
« Last Edit: April 25, 2012, 12:30:50 PM by newnixon »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GUI interaction with game
« Reply #1 on: April 25, 2012, 02:37:54 PM »
Add a script to your buttons that marks some checkbox in OnHover (true).

newnixon

  • Guest
Re: GUI interaction with game
« Reply #2 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GUI interaction with game
« Reply #3 on: April 25, 2012, 06:14:36 PM »
Script attached to a button:

  1. using UnityEngine;
  2.  
  3. public class MarkCheckboxOnClick : MonoBehaviour
  4. {
  5.         public UICheckbox checkbox;
  6.  
  7.         void OnClick ()
  8.         {
  9.                 checkbox.isChecked = true;
  10.         }
  11. }

newnixon

  • Guest
Re: GUI interaction with game
« Reply #4 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GUI interaction with game
« Reply #5 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.

newnixon

  • Guest
Re: GUI interaction with game
« Reply #6 on: April 26, 2012, 03:49:28 PM »
Yep that was it!! Just added it works now. Thanks!!