FairyGUI.Container.AddChildAt C# (CSharp) Method

AddChildAt() public method

public AddChildAt ( DisplayObject child, int index ) : DisplayObject
child DisplayObject
index int
return DisplayObject
        public DisplayObject AddChildAt(DisplayObject child, int index)
        {
            int count = _children.Count;
            if (index >= 0 && index <= count)
            {
                if (child.parent == this)
                {
                    SetChildIndex(child, index);
                }
                else
                {
                    child.RemoveFromParent();
                    if (index == count)
                        _children.Add(child);
                    else
                        _children.Insert(index, child);
                    child.InternalSetParent(this);

                    if (stage != null)
                    {
                        if (child is Container)
                            child.onAddedToStage.BroadcastCall();
                        else
                            child.onAddedToStage.Call();
                    }

                    InvalidateBatchingState(true);
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }

Usage Example

Example #1
0
 static int AddChildAt(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1);
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         FairyGUI.DisplayObject o = obj.AddChildAt(arg0, arg1);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
All Usage Examples Of FairyGUI.Container::AddChildAt