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;
}
}
}
}