Borodar.ReorderableList.ReorderableListControl.MoveItem C# (CSharp) Method

MoveItem() protected method

Move item from source index to destination index.
protected MoveItem ( IReorderableListAdaptor adaptor, int sourceIndex, int destIndex ) : void
adaptor IReorderableListAdaptor Reorderable list adaptor.
sourceIndex int Zero-based index of source item.
destIndex int Zero-based index of destination index.
return void
        protected void MoveItem(IReorderableListAdaptor adaptor, int sourceIndex, int destIndex)
        {
            // Raise event before moving item so that the operation can be cancelled.
            var movingEventArgs = new ItemMovingEventArgs(adaptor, sourceIndex, destIndex);
            OnItemMoving(movingEventArgs);
            if (!movingEventArgs.Cancel) {
                adaptor.Move(sourceIndex, destIndex);

                // Item was actually moved!
                int newIndex = destIndex;
                if (newIndex > sourceIndex)
                    --newIndex;
                OnItemMoved(new ItemMovedEventArgs(adaptor, sourceIndex, newIndex));

                GUI.changed = true;
            }
            ReorderableListGUI.IndexOfChangedItem = -1;
        }