I came across a problem that would cause a panel to move behind other objects causing its contents to disappear when dragging. After some investigation I realised the z component of the transform was being set to a very small non-zero value, I imagine due to floating point error in one of the previous operations. I changed my UIDraggablePanel.MoveRelative to
void MoveRelative (Vector3 relative)
{
mTrans.localPosition += relative;
if (mTrans.position.z != 0.0f)
{
Debug.LogError("Z problem found. Correcting!");
mTrans.position =
new Vector3(mTrans.position.x,
mTrans.position.y,
0.0f);
}
Vector4 cr = mPanel.clipRange;
cr.x -= relative.x;
cr.y -= relative.y;
mPanel.clipRange = cr;
UpdateScrollbars(false);
}
and this fixed the problem. However I don't know if this will cause problems elsewhere?
Will appreciate any thoughts on this! Thanks.