FairyGUI.GObject.RemoveFromParent C# (CSharp) Method

RemoveFromParent() public method

public RemoveFromParent ( ) : void
return void
        public void RemoveFromParent()
        {
            if (parent != null)
                parent.RemoveChild(this);
        }

Usage Example

示例#1
0
        /// <summary>
        /// Adds a child to the component at a certain index.
        /// </summary>
        /// <param name="child">A child object</param>
        /// <param name="index">Index</param>
        /// <returns>GObject</returns>
        virtual public GObject AddChildAt(GObject child, int index)
        {
            int numChildren = _children.Count;

            if (index >= 0 && index <= numChildren)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    child.InternalSetParent(this);

                    int cnt = _children.Count;
                    if (child.sortingOrder != 0)
                    {
                        _sortingChildCount++;
                        index = GetInsertPosForSortingChild(child);
                    }
                    else if (_sortingChildCount > 0)
                    {
                        if (index > (cnt - _sortingChildCount))
                        {
                            index = cnt - _sortingChildCount;
                        }
                    }

                    if (index == cnt)
                    {
                        _children.Add(child);
                    }
                    else
                    {
                        _children.Insert(index, child);
                    }

                    ChildStateChanged(child);
                    SetBoundsChangedFlag();
                    if (child.group != null)
                    {
                        child.group.SetBoundsChangedFlag(true);
                    }
                }
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index: " + index + ">" + numChildren);
            }
        }
All Usage Examples Of FairyGUI.GObject::RemoveFromParent