// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void AddChild(exUIControl _ctrl) { if (_ctrl == null) { return; } if (_ctrl.parent == this) { return; } // you can not add your parent or yourself as your child if (_ctrl.IsSelfOrAncestorOf(this)) { return; } exUIControl lastParent = _ctrl.parent; if (lastParent != null) { lastParent.RemoveChild(_ctrl); } children.Add(_ctrl); _ctrl.parent = this; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void OnDestroy() { if (parent != null) { parent.RemoveChild(this); } }