Author Topic: UISlider: Is it possible to change the "On value change" parameters by script ?  (Read 3435 times)

pat

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Dear all,

for the OnValueChange field I can specify a gameobejct and chose a function in the editor.
But I need to assign the gameobject and function during runtime, because this instance is created then and not available in the editor. It stays persistent through all the scenes.

Any ideas ?

Greetings
Pat





ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Prefabs can never keep references to stuff that's not a part of the same prefab.

Think about it. Prefabs don't exist until you create them. How can they possibly keep a reference to something outside them?

pat

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Hi,

I am not talking about prefabs.
I have a gamestate object which is created at startup of the game (awake). This object is persistent through all scene changes and provides all settings (like volume, game designs) for all scenes.

In the old (free) version of NGUI I did the following:


The function is known and can be set in the editor (public void setSoundFXVolumeValue(float newSoundFXVolumeValue))
The gameobject not, so I wrote a little script (UISliderSetGamestatInstance) which assigns the gamestate object to the event rcv field at startup time.

I am wondering how to do this in the current version of NGUI

Pat.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
EventDelegate.Set(slider.onChange, YourCallbackFunction);