FairyGUI.GComponent.SetChildIndex C# (CSharp) Method

SetChildIndex() public method

Moves a child to a certain index. Children at and after the replaced position move up.
public SetChildIndex ( GObject child, int index ) : void
child GObject A Child
index int Index
return void
        public void SetChildIndex(GObject child, int index)
        {
            int oldIndex = _children.IndexOf(child);
            if (oldIndex == -1)
                throw new ArgumentException("Not a child of this container");

            if (child.sortingOrder != 0) //no effect
                return;

            int cnt = _children.Count;
            if (_sortingChildCount > 0)
            {
                if (index > (cnt - _sortingChildCount - 1))
                    index = cnt - _sortingChildCount - 1;
            }

            _SetChildIndex(child, oldIndex, index);
        }

Usage Example

 static int SetChildIndex(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.GComponent obj  = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent));
         FairyGUI.GObject    arg0 = (FairyGUI.GObject)ToLua.CheckObject(L, 2, typeof(FairyGUI.GObject));
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.SetChildIndex(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
All Usage Examples Of FairyGUI.GComponent::SetChildIndex