Author Topic: UISlider Bug!?  (Read 2344 times)

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
UISlider Bug!?
« 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().


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider Bug!?
« Reply #1 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).

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: UISlider Bug!?
« Reply #2 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.

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: UISlider Bug!?
« Reply #3 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'.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider Bug!?
« Reply #4 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.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: UISlider Bug!?
« Reply #5 on: March 05, 2014, 11:18:23 AM »
thanks!
the problem have been solved.