Welcome,
Guest
. Please
login
or
register
.
April 28, 2026, 07:48:25 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Progresss bar at zero still shows sprite
« previous
next »
Print
Pages: [
1
]
Author
Topic: Progresss bar at zero still shows sprite (Read 5739 times)
kittikun
Newbie
Thank You
-Given: 2
-Receive: 5
Posts: 46
Progresss bar at zero still shows sprite
«
on:
February 11, 2014, 10:50:13 PM »
Hi,
It doesn't seem possible to have a "true" 0% with the progress bar since the sprite is still showing. You can see the picture taken from "Example 0 - Control Widgets"
Is there any workaround this ?
Thank you
Logged
BehindTheStone
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 135
Re: Progresss bar at zero still shows sprite
«
Reply #1 on:
February 12, 2014, 04:24:15 AM »
Well, you could do it by code.
Something like this
if
(
bar
.
value
<=
0
)
{
// deactivate sprite
}
Logged
kittikun
Newbie
Thank You
-Given: 2
-Receive: 5
Posts: 46
Re: Progresss bar at zero still shows sprite
«
Reply #2 on:
February 13, 2014, 04:47:06 AM »
Yes, I know..
I guess this was more like a feature request, it would have been nice to have a checkbox for this
Logged
Agent_007
Newbie
Thank You
-Given: 2
-Receive: 5
Posts: 27
Re: Progresss bar at zero still shows sprite
«
Reply #3 on:
February 13, 2014, 05:31:32 AM »
If you want to use Spliced sprite as progress indicator (with direct cuts), you actually might want three filled progress bars (UISprites) that create a one bar. It requires some extra work (you need three sprites instead of one, and you cannot use texture compression for the atlas), but it is doable
public
static
void
SetValueForThreePartBar
(
UISprite
[
]
parts,
float
value
)
{
int
totalWidth
=
parts
[
0
]
.
width
+
parts
[
1
]
.
width
+
parts
[
2
]
.
width
;
int
valueWidth
=
Mathf
.
RoundToInt
(
value
*
totalWidth
)
;
if
(
valueWidth
>
totalWidth
)
{
valueWidth
=
totalWidth
;
}
if
(
valueWidth
<
1
)
{
// Don't show anything
parts
[
0
]
.
fillAmount
=
0
.
0f
;
parts
[
1
]
.
fillAmount
=
0
.
0f
;
parts
[
2
]
.
fillAmount
=
0
.
0f
;
}
else
if
(
valueWidth
<=
parts
[
0
]
.
width
)
{
// Show only first part
parts
[
0
]
.
fillAmount
=
(
float
)
(
valueWidth
)
/
(
float
)
parts
[
0
]
.
width
;
parts
[
1
]
.
fillAmount
=
0
.
0f
;
parts
[
2
]
.
fillAmount
=
0
.
0f
;
}
else
if
(
valueWidth
<=
(
parts
[
0
]
.
width
+
parts
[
1
]
.
width
)
)
{
// Show first and second part
parts
[
0
]
.
fillAmount
=
1
.
0f
;
parts
[
1
]
.
fillAmount
=
(
float
)
(
valueWidth
-
parts
[
0
]
.
width
)
/
(
float
)
(
parts
[
1
]
.
width
)
;
parts
[
2
]
.
fillAmount
=
0
.
0f
;
}
else
{
// Show all three parts
parts
[
0
]
.
fillAmount
=
1
.
0f
;
parts
[
1
]
.
fillAmount
=
1
.
0f
;
parts
[
2
]
.
fillAmount
=
(
float
)
(
valueWidth
-
parts
[
0
]
.
width
-
parts
[
1
]
.
width
)
/
(
float
)
(
parts
[
2
]
.
width
)
;
}
}
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Progresss bar at zero still shows sprite