Using NGUI 3.6.8
Hi. I would really appreciate if you looked into this issue and maybe help us find a solution.
Basically we get the bug when we disable a sprite's current panel and then switch it to another one in the same function call.
The sprite seems to grow visually even though its size remains the same.
Initial selection.

Several transitions later...

Stripped down code that reproduces the bug.
public class FocusChanger : MonoBehaviour {
public UISprite FocusIndicator; //Red sprite (sliced). Initial parent is UIRoot
public UIWidget focusLeft; // left zone. Under "Panel"
public UIWidget focusRight; // right zone. Under "OtherPanel"
public UIPanel parentPanel; // "OtherPanel"
bool leftSelected = false;
void Start()
{
ChangeFocus(focusLeft);
leftSelected = true;
}
void ChangeFocus(UIWidget focusZone)
{
//reparent
FocusIndicator.transform.parent = focusZone.transform.parent;
FocusIndicator.transform.localPosition = focusZone.transform.localPosition;
if(FocusIndicator.panel != focusZone.panel)
{
if(FocusIndicator.panel != null)
FocusIndicator.panel.Refresh(); //necessary so that red sprite doesnt linger
FocusIndicator.panel = focusZone.panel;
//do this so that setter in UIWidget's depth property updates panel
FocusIndicator.depth = FocusIndicator.depth == Int32.MaxValue ? Int32.MaxValue - 1 : Int32.MaxValue;
}
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Backspace))
{
if(leftSelected)
{
NGUITools.SetActive(parentPanel.gameObject, true);
ChangeFocus(focusRight);
}
else
{
NGUITools.SetActive(parentPanel.gameObject, false);
ChangeFocus(focusLeft);
}
leftSelected = !leftSelected;
}
}
}
Layout

Switching the order of the two lines in the else statement makes the bug go away, but my actual project is complex enough so that changing the order of these two events would require some ugly refactoring.