// class variable
private bool childrenEnabled = true;
// ... this below is part of "void Update()" ...
// If visible, update the position
if (isVisible)
{
if (!childrenEnabled)
{
childrenEnabled = true;
for (int x = 0; x < this.transform.childCount;x++)
{
NGUITools.SetActive(this.transform.GetChild(x).gameObject, true);
}
}
transform.position = mUICamera.ViewportToWorldPoint(pos);
pos = transform.localPosition;
pos.x = Mathf.RoundToInt(pos.x);
pos.y = Mathf.RoundToInt(pos.y);
pos.z = 0f;
transform.localPosition = pos;
}
else
{
if (childrenEnabled)
{
childrenEnabled = false;
for (int x = 0; x < this.transform.childCount; x++)
{
NGUITools.SetActive(this.transform.GetChild(x).gameObject, false);
}
}
}