Welcome,
Guest
. Please
login
or
register
.
April 21, 2026, 03:53:21 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Scroll View Question
« previous
next »
Print
Pages: [
1
]
Author
Topic: Scroll View Question (Read 5551 times)
Magic Frame
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 30
Scroll View Question
«
on:
October 22, 2013, 05:16:45 AM »
Hi,
I'm creating a Scroll View, I was wondering how to make each scroll bar graph view to present a different, alternating between one color and another color, leave a picture for better understanding.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Scroll View Question
«
Reply #1 on:
October 22, 2013, 07:58:14 PM »
Since you're the one who's adding items to the scroll view, nothing is preventing you from having a background sprite on your entries and changing its color when you add new entries.
Logged
Magic Frame
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 30
Re: Scroll View Question
«
Reply #2 on:
October 23, 2013, 03:33:04 AM »
If I get that, but as I can know when it comes one color or another?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Scroll View Question
«
Reply #3 on:
October 23, 2013, 10:02:40 PM »
If (number of transform.childCount is even), use one color.
else, use another color.
Logged
Magic Frame
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 30
Re: Scroll View Question
«
Reply #4 on:
November 15, 2013, 12:33:26 PM »
Hi Aren, thanks for reply, I'm trying and I can not get it to work, when I access the children have only the last note, do not tell me what the 1,2,3,4 .... any suggestions, leave the code
using
UnityEngine
;
using
System.Collections
;
public
class
BarGraphics
:
MonoBehaviour
{
public
int
childNumber
;
// Use this for initialization
void
Start
(
)
{
}
// Update is called once per frame
void
Update
(
)
{
childNumber
=
GameObject
.
Find
(
"Gridplayer"
)
.
transform
.
childCount
%
2
;
if
(
childNumber
==
0
)
{
//Is Odd!!!
}
else
{
//Is Even!!!
}
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Scroll View Question
«
Reply #5 on:
November 15, 2013, 09:39:34 PM »
Never use GameObject.Find. It's very, very slow... and using it inside Update() -- which happens every frame -- is even worse.
Assuming this script of yours is attached to a row component, checking for the number of children in the update isn't the right place. You need to do it wherever you add the children. If you can't do it there, then do it once inside Start(). And instead of checking the total child count, you'd want to:
for
(
int
i
=
0
;
i
<
transform
.
parent
.
childCount
;
++
i
)
{
if
(
transform
.
parent
.
GetChild
(
i
)
==
transform
)
{
// here you'd do (i % 2)
break
;
}
}
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Scroll View Question