Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: gyd on March 03, 2014, 06:27:46 AM

Title: UISlider Bug!?
Post by: gyd on March 03, 2014, 06:27:46 AM
i have a prefab with UISlider,
and used by script :

  1. GameObject obj = GameObject.Instantiate( prefab ) as GameObject;
  2. UISlider _bar = obj.GetComponent<UISlider>();
  3. _bar.value = 0f;
  4.  

but the _bar.value will be always replaced by 1 when Upgrade().

Title: Re: UISlider Bug!?
Post by: ArenMook on March 03, 2014, 11:20:42 PM
What do you mean by "Upgrade"?

Also never use Instantiate.

You need to use NGUITools.AddChild(parent, prefab).
Title: Re: UISlider Bug!?
Post by: gyd on March 04, 2014, 06:59:19 AM
What do you mean by "Upgrade"?

Also never use Instantiate.

You need to use NGUITools.AddChild(parent, prefab).

i mean the Upgrade() function in UISlider script, the Direction.Upgraded never been stored back to the prefab, it will always set as 1 after Upgrade().

and, i will use NGUITools.AddChild then, thanks.
Title: Re: UISlider Bug!?
Post by: rain on March 04, 2014, 08:37:46 AM
Try dragging the prefab into the scene, enabling and disabling the slider script and then saving the prefab.
I suppose your UISlider instance is still stuck in 'legacy mode'.
Title: Re: UISlider Bug!?
Post by: ArenMook on March 05, 2014, 07:45:19 AM
Yeah sounds like it is. What rain suggested should do the trick. Be sure to Apply the changes on the prefab after it's in the scene.
Title: Re: UISlider Bug!?
Post by: gyd on March 05, 2014, 11:18:23 AM
thanks!
the problem have been solved.