private void ClearSelectionAndSelectObject(GameObject gameObject)
        {
            ObjectSelection           objectSelection     = ObjectSelection.Get();
            ObjectSelectionUpdateMode selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode;

            if (selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy)
            {
                UndoEx.RecordForToolAction(objectSelection);
                objectSelection.Clear();
                objectSelection.AddEntireGameObjectHierarchyToSelection(gameObject);
                objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick();
            }
            else
            {
                // Note: We only continue if the picked object is not the only currently selected object. If it is, it means
                //       we would be registering an Undo operation for nothing.
                if (!ObjectSelection.Get().IsSameAs(gameObject))
                {
                    UndoEx.RecordForToolAction(objectSelection);
                    objectSelection.Clear();
                    objectSelection.AddGameObjectToSelection(gameObject);
                    objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick();
                }
            }
        }
        private void ToggleObjectSelectedState(GameObject gameObject)
        {
            ObjectSelection           objectSelection     = ObjectSelection.Get();
            ObjectSelectionUpdateMode selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode;

            UndoEx.RecordForToolAction(objectSelection);

            if (selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy)
            {
                if (objectSelection.IsGameObjectSelected(gameObject))
                {
                    objectSelection.RemoveEntireGameObjectHierarchyFromSelection(gameObject);
                }
                else
                {
                    objectSelection.AddEntireGameObjectHierarchyToSelection(gameObject);
                }
            }
            else
            {
                if (objectSelection.IsGameObjectSelected(gameObject))
                {
                    objectSelection.RemoveGameObjectFromSelection(gameObject);
                }
                else
                {
                    objectSelection.AddGameObjectToSelection(gameObject);
                }
            }
            objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick();
        }
示例#3
0
        private void AppendObjectsToSelection(List <GameObject> gameObjectsOverlappedBySelectionShape)
        {
            if (gameObjectsOverlappedBySelectionShape.Count != 0)
            {
                ObjectSelection           objectSelection      = ObjectSelection.Get();
                ObjectSelectionUpdateMode _selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode;

                // Note: We only continue if the current object selection is not the same as the
                //       collection of objects we are appending. If it is, we would be registering
                //       an unnecessary Undo operation.
                if (!objectSelection.IsSameAs(gameObjectsOverlappedBySelectionShape))
                {
                    if (_selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy)
                    {
                        UndoEx.RecordForToolAction(objectSelection);
                        objectSelection.AddEntireGameObjectHierarchyToSelection(gameObjectsOverlappedBySelectionShape);
                    }
                    else
                    {
                        UndoEx.RecordForToolAction(objectSelection);
                        objectSelection.AddGameObjectCollectionToSelection(gameObjectsOverlappedBySelectionShape);
                    }
                    objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingSelectionShape();
                }
            }
        }
示例#4
0
        private void UpdateSelectionForNoAppendAndNoDeselect(List <GameObject> gameObjectsOverlappedBySelectionShape)
        {
            ObjectSelection           objectSelection      = ObjectSelection.Get();
            ObjectSelectionUpdateMode _selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode;

            // If no object was overlapped by the selection shape, we can clear the selection.
            // Note: We only clear the selection if the current number of selected objects is not 0. This
            //       allows us to avoid registering an Undo for nothing.
            if (gameObjectsOverlappedBySelectionShape.Count == 0 && objectSelection.NumberOfSelectedObjects != 0)
            {
                UndoEx.RecordForToolAction(objectSelection);
                objectSelection.Clear();
            }
            else
            // When the selection shape has overlapped objects, we must reset the selection by clearing it and selecting only
            // the objects which were overlapped.
            if (gameObjectsOverlappedBySelectionShape.Count != 0)
            {
                UndoEx.RecordForToolAction(objectSelection);
                objectSelection.Clear();

                if (_selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy)
                {
                    objectSelection.AddEntireGameObjectHierarchyToSelection(gameObjectsOverlappedBySelectionShape);
                }
                else
                {
                    objectSelection.AddGameObjectCollectionToSelection(gameObjectsOverlappedBySelectionShape);
                }
                objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingSelectionShape();
            }
        }
示例#5
0
        private void RenderSelectionUpdateModeSelectionPopup()
        {
            ObjectSelectionUpdateMode newSelectionUpdateMode = (ObjectSelectionUpdateMode)EditorGUILayout.EnumPopup(GetCotentForSelectionUpdateModeSelectionToggle(), _settings.SelectionUpdateMode);

            if (newSelectionUpdateMode != _settings.SelectionUpdateMode)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.SelectionUpdateMode = newSelectionUpdateMode;
            }
        }
示例#6
0
        private void DeselectObjectsWithSelectionShape(List <GameObject> gameObjectsOverlappedBySelectionShape)
        {
            if (gameObjectsOverlappedBySelectionShape.Count != 0)
            {
                ObjectSelection           objectSelection      = ObjectSelection.Get();
                ObjectSelectionUpdateMode _selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode;

                if (_selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy)
                {
                    UndoEx.RecordForToolAction(objectSelection);
                    objectSelection.RemoveEntireGameObjectHierarchyFromSelection(gameObjectsOverlappedBySelectionShape);
                }
                else
                {
                    UndoEx.RecordForToolAction(objectSelection);
                    objectSelection.RemoveGameObjectCollectionFromSelection(gameObjectsOverlappedBySelectionShape);
                }
                objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingSelectionShape();
            }
        }
 public static ObjectSelectionUpdateMode GetNext(ObjectSelectionUpdateMode selectionUpdateMode)
 {
     return((ObjectSelectionUpdateMode)(((int)selectionUpdateMode + 1) % _count));
 }