Welcome,
Guest
. Please
login
or
register
.
April 24, 2026, 10:36:39 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UISlider bug
« previous
next »
Print
Pages: [
1
]
Author
Topic: UISlider bug (Read 7640 times)
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
UISlider bug
«
on:
March 09, 2014, 05:15:59 PM »
This code doesn't work:
float
energy
=
0
;
void
Update
(
)
{
energy
+=
(
1
*
Time
.
deltaTime
)
;
GameObject
.
Find
(
"Control - Simple Progress Bar"
)
.
GetComponent
<
UISlider
>
(
)
.
value
=
(
energy
/
100
)
;
}
To fix it I must use:
float
energy
=
0
;
void
Update
(
)
{
energy
+=
(
1
*
Time
.
deltaTime
)
;
GameObject
.
Find
(
"Control - Simple Progress Bar"
)
.
GetComponent
<
UISlider
>
(
)
.
value
=
(
float
)
(
System
.
Math
.
Truncate
(
(
double
)
(
energy
/
100
)
*
100.0
)
/
100.0
)
;
}
Is very easy to reproduce.
I think this should be fixed.
Logged
cyx
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 17
Re: UISlider bug
«
Reply #1 on:
March 09, 2014, 05:33:56 PM »
how about:
float
energy
=
0f
;
UISlider slider
;
void
Awake
(
)
{
slider
=
GameObject
.
Find
(
"Control - Simple Progress Bar"
)
.
GetComponent
<
UISlider
>
(
)
;
}
void
Update
(
)
{
energy
+=
Time
.
deltaTime
;
slider
.
value
=
energy
/
100f
;
}
I would suggest to find the object and component only once, if you need it in the update cycle. And 100f should work if you wanna be sure to get a float result.
Logged
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Re: UISlider bug
«
Reply #2 on:
March 09, 2014, 06:11:19 PM »
Yes I know it, I posted scipt in that way so as to make easy finding problems.
Logged
BeShifty
Jr. Member
Thank You
-Given: 5
-Receive: 7
Posts: 52
Re: UISlider bug
«
Reply #3 on:
March 09, 2014, 08:27:41 PM »
Could you describe what's happening?
Logged
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Re: UISlider bug
«
Reply #4 on:
March 10, 2014, 05:36:08 AM »
UISlider value change without graphic modification.
Logged
Noi14
Jr. Member
Thank You
-Given: 10
-Receive: 0
Posts: 57
Re: UISlider bug
«
Reply #5 on:
March 10, 2014, 05:56:24 AM »
Here a video:
http://www.youtube.com/watch?v=NSP0XVozack&feature=youtu.be
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UISlider bug
«
Reply #6 on:
March 10, 2014, 07:28:37 PM »
Comment out line 131 in UIProgressBar.cs:
//if (Mathf.Abs(before - this.value) > 0.001f)
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UISlider bug