Welcome,
Guest
. Please
login
or
register
.
May 06, 2026, 07:16:35 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIGrid.ResetPosition() bug?
« previous
next »
Print
Pages: [
1
]
Author
Topic: UIGrid.ResetPosition() bug? (Read 5781 times)
rayfung
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 1
UIGrid.ResetPosition() bug?
«
on:
July 26, 2017, 12:00:11 AM »
The children of myTrans may contain inactive elements. Maybe loop through "list" is better?
What happens if change the last loop statement to loop through "list"?
protected
virtual
void
ResetPosition
(
List
<
Transform
>
list
)
{
//Ignore some code here
//.........................
// Apply the origin offset
if
(
pivot
!=
UIWidget
.
Pivot
.
TopLeft
)
{
Vector2 po
=
NGUIMath
.
GetPivotOffset
(
pivot
)
;
float
fx, fy
;
if
(
arrangement
==
Arrangement
.
Horizontal
)
{
fx
=
Mathf
.
Lerp
(
0f, maxX
*
cellWidth, po
.
x
)
;
fy
=
Mathf
.
Lerp
(
-
maxY
*
cellHeight, 0f, po
.
y
)
;
}
else
{
fx
=
Mathf
.
Lerp
(
0f, maxY
*
cellWidth, po
.
x
)
;
fy
=
Mathf
.
Lerp
(
-
maxX
*
cellHeight, 0f, po
.
y
)
;
}
for
(
int
i
=
0
;
i
<
myTrans
.
childCount
;
++
i
)
//Question: why loop through children of myTrans instead of list?
{
Transform t
=
myTrans
.
GetChild
(
i
)
;
SpringPosition sp
=
t
.
GetComponent
<
SpringPosition
>
(
)
;
if
(
sp
!=
null
)
{
sp
.
target
.
x
-=
fx
;
sp
.
target
.
y
-=
fy
;
}
else
{
Vector3 pos
=
t
.
localPosition
;
pos
.
x
-=
fx
;
pos
.
y
-=
fy
;
t
.
localPosition
=
pos
;
}
}
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIGrid.ResetPosition() bug?
«
Reply #1 on:
August 03, 2017, 03:39:27 AM »
Change it and find out
To be honest this code is ~6 years old, so I don't remember why it was the way it was, or if there was even a reason. I'll also change it on my end just to see if it breaks.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIGrid.ResetPosition() bug?