Author Topic: Set bool OnClick using Notify not working  (Read 3399 times)

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
Set bool OnClick using Notify not working
« on: April 21, 2014, 08:09:35 AM »
Hey all,

This is probably something really obvious and Im just being a bit thick but I can not get it to work,

I have a GUI button that has a gameobject attached to the Notify part. This triggers the Function MyClickFunction() and it SHOULD change the bool from false to true but it does not. However the Debug.Log is posting so I know its running the function.

Any ideas? Here is the script

  1. public class ButtonClickTrigger: BaseTrigger
  2. {
  3.         public bool _buttonPressed = false;
  4.  
  5.  
  6.         public void MyClickFunction()
  7.         {
  8.                 _buttonPressed = true;
  9.                 Debug.Log ("Button Was clicked");
  10.         }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set bool OnClick using Notify not working
« Reply #1 on: April 22, 2014, 04:16:12 AM »
If you see the Debug.Log, then it most certainly changes the value of your bool. Try printing it out in place of your Debug.Log, and print NGUITools.GetHierarchy(gameObject) as well to make sure you're targeting the right object.

will_brett

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 40
    • View Profile
Re: Set bool OnClick using Notify not working
« Reply #2 on: April 22, 2014, 05:43:26 AM »
Thanks Aren, I will try this later today