Beispiel #1
0
        /// <inheritdoc/>
        public void DeleteMember(IDrawer delete)
        {
            int index = Array.IndexOf(members, delete);

            if (index == -1)
            {
                Debug.LogError(ToString() + ".DeleteMemberValue - Unable to find item " + (delete == null ? "null" : delete.ToString()) + " among members");
                return;
            }

            var setVisibleMembers   = visibleMembers;
            int visibleMembersIndex = Array.IndexOf(visibleMembers, delete);

            if (visibleMembersIndex != -1)
            {
                DrawerArrayPool.RemoveAt(ref setVisibleMembers, visibleMembersIndex, false, false);
            }

            var setMembers = members;

            DrawerArrayPool.RemoveAt(ref setMembers, index, false, true);

            SetMembers(setMembers, setVisibleMembers, true);

            inspector.RefreshView();
        }
Beispiel #2
0
        /// <inheritdoc/>
        public void OnMemberDragNDrop(MouseDownInfo mouseDownInfo, Object[] draggedObjects)
        {
            var reordering = mouseDownInfo.Reordering;

            int dropIndex = reordering.MouseoveredDropTarget.MemberIndex;

            if (dropIndex >= 0)
            {
                var draggedGameObjectDrawer = reordering.Drawer;

                //if only raw GameObject references are dragged, e.g. from the hierarchy view
                if (draggedGameObjectDrawer == null)
                {
                    var gameObjects = draggedObjects as GameObject[];
                    if (gameObjects != null)
                    {
                        var inspector = Inspector;

                                                #if DEV_MODE && PI_ASSERTATIONS
                        Debug.Assert(reordering.MouseoveredDropTarget.Inspector == inspector);
                                                #endif

                        //create a new GameObjectGUIInstrutions to display the dragged GameObjects
                        var gameObjectDrawer = inspector.DrawerProvider.GetForGameObjects(inspector, gameObjects, this);
                        if (gameObjectDrawer != null)
                        {
                            var setMembers = Members;
                            DrawerArrayPool.InsertAt(ref members, dropIndex, gameObjectDrawer, false);
                            SetMembers(setMembers, true);
                        }
                    }
                }
                else
                {
                    var sourceParent = reordering.Parent;
                    int sourceIndex  = reordering.MemberIndex;

                    //if reordering GameObjects within the same DrawerGroup (e.g. stacked multi-editing mode)
                    if (sourceParent == this)
                    {
                        if (dropIndex != sourceIndex)
                        {
                            inspector.State.ViewIsLocked = true;

                            var setMembers = Members;
                            DrawerArrayPool.RemoveAt(ref setMembers, sourceIndex, false, false);

                            if (sourceIndex < dropIndex)
                            {
                                dropIndex--;
                            }
                            DrawerArrayPool.InsertAt(ref setMembers, dropIndex, draggedGameObjectDrawer, false);

                            SetMembers(setMembers);
                        }
                    }
                    //if cloning (or moving?) GameObjects from one DrawerGroup to another (e.g. between split views)
                    else
                    {
                        var setMembers = Members;
                        var clone      = inspector.DrawerProvider.GetForGameObjects(reordering.MouseoveredDropTarget.Inspector, draggedGameObjectDrawer.GetValues() as GameObject[], this);
                        DrawerArrayPool.InsertAt(ref setMembers, dropIndex, clone, false);
                        SetMembers(setMembers);
                    }
                }
            }
        }