Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: kruncher on December 07, 2013, 09:18:29 AM

Title: Problem with UISlider with Vertical Filled Sprite
Post by: kruncher on December 07, 2013, 09:18:29 AM
Okay, this is working in the previous asset store release of NGUI, but has broken in the latest release.

I have a sprite which is just a green circle which is used as a vertical progress meter. I have another script which keeps its value in sync with the game state.

When the game first starts the meter becomes squashed, and remains squashed for the duration of the game. During play mode, if I delete the widget and then select Edit|Undo it corrects itself.

If I remove "mySlider.value = healthPercentage;" from within the "Update" function of my script it also behaves. The problem only seems to occur when the game first instantiates the GUI from a prefab. If I begin the game with my update script disabled, and then enabled it in-game, the widget renders properly.

Here is a screenshot:
http://pbrd.co/IRCFMl

The widget on the left is how it incorrectly looks upon starting the game. The widget on the right is how it should look.

If the widget on the left is duplicated (Ctrl+D) during play mode, it appears properly (the one on the right is a clone).
Title: Re: Problem with UISlider with Vertical Filled Sprite
Post by: kruncher on December 07, 2013, 09:23:18 AM
The problem seems to occur if the first update is less than 1 (as is the case in that screenshot). Perhaps this is some sort of execution order issue?

Edit: I set the execution order for UISlider to -100 and this resolved the problem. So it seems that the default execution order is different for the new version of NGUI... or perhaps an implementation change which has become dependent upon execution order.
Title: Re: Problem with UISlider with Vertical Filled Sprite
Post by: ArenMook on December 07, 2013, 03:48:37 PM
I know what it is. You're basically setting the value before the slider realizes that it's working with a filled sprite. I'll add in extra code in there, thanks!