Author Topic: Why does popup list triggers in the Start function?  (Read 4288 times)

Shorinji

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Why does popup list triggers in the Start function?
« on: June 22, 2012, 09:00:36 AM »
Hi,
I want to use a popup menu which contains a popup list.
When i launch my game, "Function Name" is called because inside Start(), "selection" is set to something.
Why did you choose this behavior to happen?
Thanks in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why does popup list triggers in the Start function?
« Reply #1 on: June 22, 2012, 10:54:35 AM »
The callback function is invoked in Start -- it's the same behaviour as other NGUI scripts -- checkbox, for example. This is for consistency purposes. The selected item is both highlighted, and whatever the callback is supposed to do also happens. For example if you loaded something from player prefs in awake and set the value of the popup list, and the callback function was changing the game map (and the game map texture), without this functionality the game map would never change to the selected value, which would be wrong.

Shorinji

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Why does popup list triggers in the Start function?
« Reply #2 on: June 23, 2012, 12:55:12 AM »
Hi,
Actually after more tries, think this component doesn't really fit for what i need. I need something which would more look like a "pop up buttons list", no trigger at start, and trigger again even if the selected item is the same than the previously selected item. However it doesn't exist (or i did not see it).
So i have other questions.
From a license point of view, do i have the right to modify the scripts provided with NGUI? Do i have the right to make new components myself based on NGUI architecture?
Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why does popup list triggers in the Start function?
« Reply #3 on: June 23, 2012, 03:35:05 AM »
Of course you can. I suggest creating new scripts / widgets rather than modifying existing ones though. It'll make updating easier.