protected void SetParent(EditorGUIWidget widget) { if (parent == widget || this == widget) { return; } if (parent != null) { parent.RemoveChild(this); } if (widget != null) { widget.AddChild(this); parent = widget; } else { localPostion = worldPostion; return; } float x = 0, y = 0; var tempParent = parent; while (tempParent != null) { x += tempParent.localPostion.x; y += tempParent.localPostion.y; tempParent = tempParent.Parent; } localPostion.x = worldPostion.x - x; localPostion.y = worldPostion.y - y; RefreshArea(); }