private void OnItemBeginDrop(object sender, ItemDropCancelArgs e)
 {
     if (e.IsExternal)
     {
     }
     else
     {
         RuntimeUndo.BeginRecord();
         for (int i = 0; i < e.DragItems.Length; ++i)
         {
             Transform dragT = ((GameObject)e.DragItems[i]).transform;
             RuntimeUndo.RecordTransform(dragT, dragT.parent, dragT.GetSiblingIndex());
             RuntimeUndo.RecordObject(dragT.gameObject, m_treeView.IndexOf(dragT.gameObject), RestoreIndexFromUndoRecord);
         }
         RuntimeUndo.EndRecord();
     }
 }
        private void OnItemDrop(object sender, ItemDropArgs e)
        {
            if (e.IsExternal)
            {
            }
            else
            {
                Transform dropT = ((GameObject)e.DropTarget).transform;
                if (e.Action == ItemDropAction.SetLastChild)
                {
                    RuntimeUndo.BeginRecord();
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        Transform dragT = ((GameObject)e.DragItems[i]).transform;
                        dragT.SetParent(dropT, true);
                        dragT.SetAsLastSibling();

                        RuntimeUndo.RecordTransform(dragT, dropT, dragT.GetSiblingIndex());
                        RuntimeUndo.RecordObject(dragT.gameObject, m_treeView.IndexOf(dragT.gameObject), RestoreIndexFromUndoRecord);
                    }
                    RuntimeUndo.EndRecord();
                }
                else if (e.Action == ItemDropAction.SetNextSibling)
                {
                    RuntimeUndo.BeginRecord();
                    for (int i = e.DragItems.Length - 1; i >= 0; --i)
                    {
                        Transform dragT      = ((GameObject)e.DragItems[i]).transform;
                        int       dropTIndex = dropT.GetSiblingIndex();
                        if (dragT.parent != dropT.parent)
                        {
                            dragT.SetParent(dropT.parent, true);
                            dragT.SetSiblingIndex(dropTIndex + 1);
                        }
                        else
                        {
                            int dragTIndex = dragT.GetSiblingIndex();
                            if (dropTIndex < dragTIndex)
                            {
                                dragT.SetSiblingIndex(dropTIndex + 1);
                            }
                            else
                            {
                                dragT.SetSiblingIndex(dropTIndex);
                            }
                        }

                        RuntimeUndo.RecordTransform(dragT, dropT.parent, dragT.GetSiblingIndex());
                        RuntimeUndo.RecordObject(dragT.gameObject, m_treeView.IndexOf(dragT.gameObject), RestoreIndexFromUndoRecord);
                    }

                    RuntimeUndo.EndRecord();
                }
                else if (e.Action == ItemDropAction.SetPrevSibling)
                {
                    RuntimeUndo.BeginRecord();
                    for (int i = 0; i < e.DragItems.Length; ++i)
                    {
                        Transform dragT = ((GameObject)e.DragItems[i]).transform;
                        if (dragT.parent != dropT.parent)
                        {
                            dragT.SetParent(dropT.parent, true);
                        }

                        int dropTIndex = dropT.GetSiblingIndex();
                        int dragTIndex = dragT.GetSiblingIndex();
                        if (dropTIndex > dragTIndex)
                        {
                            dragT.SetSiblingIndex(dropTIndex - 1);
                        }
                        else
                        {
                            dragT.SetSiblingIndex(dropTIndex);
                        }

                        RuntimeUndo.RecordTransform(dragT, dropT.parent, dragT.GetSiblingIndex());
                        RuntimeUndo.RecordObject(dragT.gameObject, m_treeView.IndexOf(dragT.gameObject), RestoreIndexFromUndoRecord);
                    }
                    RuntimeUndo.EndRecord();
                }
            }
        }