Author Topic: On Value Change triggered when panel is first enabled  (Read 6064 times)

stapledon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
On Value Change triggered when panel is first enabled
« on: February 20, 2014, 09:12:27 AM »
As the subject says, how do we stop UI elements such as UISliders from triggering their Value Change Notify when a panel is first enabled?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: On Value Change triggered when panel is first enabled
« Reply #1 on: February 20, 2014, 09:16:42 AM »
You can't. This is intentional so that all associated values have the up-to-date state.

stapledon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: On Value Change triggered when panel is first enabled
« Reply #2 on: February 20, 2014, 09:32:10 AM »
Associated values? Internal to NGUI you mean?






ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: On Value Change triggered when panel is first enabled
« Reply #3 on: February 20, 2014, 09:37:55 AM »
No. Think of it like this.

1. You create a prefab of a slider that updates a numerical value on  a label.
2. The slider is on a panel that's disabled by default (think options panel).
3. You have a script that changes the slider's value (while the slider is still disabled).
4. You now enable the panel. If the callback function doesn't get called, there will now be a discrepancy between the slider's value, and the associated numerical value. The slider will show one thing, but the label -- another.

stapledon

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: On Value Change triggered when panel is first enabled
« Reply #4 on: February 20, 2014, 09:55:23 AM »
That's fine for that sort of case - and that's the majority of cases I'm sure. I ask this because we have cases where we have to write a lot of init code to ignore UI calls with the way our UI integration is set up - it's simple enough to do, but you start noticing it when you're doing it a lot, and it's probably not the best way of doing things in every case, but for this particular project it's a necessary evil.

No biggy anyway, I understand it's not generally going to be a typical issue, but if it doesn't break anything then a Notify On Active checkbox wouldn't go unappreciated. ; )