public List <GameObject> GetOverlappedGameObjects()
 {
     if (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Standard)
     {
         // Note: We will only select objects if at least one of the enclosing rectangle dimensions
         //       is >= 'minRectSize'. This helps avoid situations in which the user wants to click on
         //       a game object, but they accodentally drag the mouse a little bit which causes unwanted
         //       objects to be selected.
         const int minRectSize          = 15;
         ObjectInteraction2DShape shape = GetShape();
         Rect enclosingRectangle        = shape.EnclosingRect;
         if (Mathf.Abs(enclosingRectangle.size.x) >= minRectSize ||
             Mathf.Abs(enclosingRectangle.size.y) >= minRectSize)
         {
             return(shape.GetOverlappedGameObjects(ObjectSelectionSettings.Get().AllowPartialOverlap));
         }
         else
         {
             return(new List <GameObject>());
         }
     }
     else
     {
         return(GetShape().GetOverlappedGameObjects(ObjectSelectionSettings.Get().AllowPartialOverlap));
     }
 }
        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();
                }
            }
        }
예제 #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();
                }
            }
        }
        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();
        }
예제 #5
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();
            }
        }
예제 #6
0
        public ObjectSelectionSettingsView(ObjectSelectionSettings settings)
        {
            _settings = settings;

            ToggleVisibilityBeforeRender = true;
            VisibilityToggleLabel        = "Object Selection Settings";
            SurroundWithBox = true;
        }
예제 #7
0
        private void AcquireAppendAndDeselectStates()
        {
            _mustDeselectObjects = AllShortcutCombos.Instance.EnableDeselectObjectsWithSelectionShape.IsActive();

            // Note: We append only if:
            //  -the append shortcut is active;
            //  -the selection mode is set to 'Paint' and the user is not intending on deselecting objects with the object selection shape.
            _mustAppendObjectsToSelection = AllShortcutCombos.Instance.EnableAppendObjectsToSelection.IsActive() ||
                                            (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Paint && !_mustDeselectObjects);
        }
 public void HandleMouseButtonUpEvent(Event e)
 {
     if (e.InvolvesLeftMouseButton())
     {
         _isVisibleForStandardMode = false;
         if (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Standard)
         {
             SceneView.RepaintAll();
         }
     }
 }
예제 #9
0
        private static void SaveObjectSelectionSettings(XmlTextWriter xmlWriter, Octave3DConfigSaveLoadSettings saveSettings)
        {
            if (saveSettings.ObjectSelectionSettings)
            {
                ObjectSelectionSettings objectSelectionSettings = ObjectSelectionSettings.Get();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionSettingsNode);

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionAllowPartialOverlapNode);
                xmlWriter.WriteString(objectSelectionSettings.AllowPartialOverlap.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.AttachMirroredSelectedObjectsToActiveGroupNodeNode);
                xmlWriter.WriteString(objectSelectionSettings.AttachMirroredObjectsToActiveObjectGroup.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionShapeTypeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionShapeType.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionUpdateModeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionUpdateMode.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionModeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionMode.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_ShapePixelWidthNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.SelectionShapeWidthInPixels.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_ShapePixelHeightNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.SelectionShapeHeightInPixels.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_SizeAdjustmentSpeedScrollWheelNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.ScrollWheelShapeSizeAdjustmentSpeed.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteEndElement();
            }
        }
예제 #10
0
        public bool IsVisible()
        {
            if (!MouseCursor.Instance.IsInsideSceneView())
            {
                return(false);
            }
            if (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Standard)
            {
                return(_isVisibleForStandardMode);
            }

            return(true);
        }
예제 #11
0
        private void OnBeforeRender()
        {
            ObjectSelectionSettings selectionSettings = ObjectSelectionSettings.Get();

            if (selectionSettings.SelectionMode == ObjectSelectionMode.Paint)
            {
                ObjectSelectionPaintModeSettings paintModeSettings = selectionSettings.PaintModeSettings;
                SetWidthHeight(paintModeSettings.SelectionShapeWidthInPixels, paintModeSettings.SelectionShapeHeightInPixels);

                GetShape().EnclosingRectCenter = Event.current.InvMousePos(SceneViewCamera.Camera);
                SceneView.RepaintAll();
            }
        }
예제 #12
0
        public void HandleMouseButtonDownEvent(Event e)
        {
            if (e.InvolvesLeftMouseButton())
            {
                e.DisableInSceneView();

                _isVisibleForStandardMode = true;
                if (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Standard)
                {
                    GetShape().SetEnclosingRectMinMaxPoints(e.InvMousePos(SceneViewCamera.Camera));
                }
            }
        }
예제 #13
0
 public void HandleMouseDragEvent(Event e)
 {
     if (e.InvolvesLeftMouseButton())
     {
         if (ObjectSelectionSettings.Get().SelectionMode == ObjectSelectionMode.Standard)
         {
             AdjustStandardShapeSizeForMouseDragEvent(e);
         }
         if (!MouseCursor.Instance.IsInsideSceneView())
         {
             _isVisibleForStandardMode = false;
         }
     }
 }
예제 #14
0
        public override void Render()
        {
            RenderSelectionTransformGizmoSystemControls();

            _objectSelectionActionsToolbar.Render();
            _objectSelectionActionsView.Render();

            ObjectSelection.Get().MirrorView.Render();
            Octave3DWorldBuilder.ActiveInstance.PlacementObjectGroupDatabase.View.Render();
            ObjectSelectionSettings.Get().View.Render();
            ObjectSelectionPrefabCreationSettings.Get().View.Render();
            ObjectSelection.Get().ObjectOnSurfaceProjectSettings.RenderView();
            _lookAndFeelSettingsView.Render();
        }
예제 #15
0
        private ObjectInteraction2DShape GetShape()
        {
            ObjectSelectionSettings selectionSettings = ObjectSelectionSettings.Get();

            if (selectionSettings.SelectionShapeType == ObjectSelectionShapeType.Ellipse)
            {
                return(_ellipseShape);
            }
            else if (selectionSettings.SelectionShapeType == ObjectSelectionShapeType.Rectangle)
            {
                return(_rectangleShape);
            }

            return(null);
        }
예제 #16
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();
            }
        }
예제 #17
0
        private static void SaveObjectSelectionSettings(XmlTextWriter xmlWriter, Octave3DConfigSaveLoadSettings saveSettings)
        {
            if (saveSettings.ObjectSelectionSettings)
            {
                ObjectSelectionSettings objectSelectionSettings = ObjectSelectionSettings.Get();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionSettingsNode);

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionAttachToObjectGroupNode);
                xmlWriter.WriteString(objectSelectionSettings.ObjectGroupSettings.AttachToObjectGroup.ToString());
                xmlWriter.WriteEndElement();

                if (objectSelectionSettings.ObjectGroupSettings.DestinationGroup != null &&
                    objectSelectionSettings.ObjectGroupSettings.DestinationGroup.GroupObject != null)
                {
                    xmlWriter.WriteNewLine(2);
                    xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionDestinationObjectGroupNode);
                    xmlWriter.WriteString(objectSelectionSettings.ObjectGroupSettings.DestinationGroup.GroupObject.name);
                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionXRotationStepNode);
                xmlWriter.WriteString(objectSelectionSettings.XRotationStep.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionYRotationStepNode);
                xmlWriter.WriteString(objectSelectionSettings.YRotationStep.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionZRotationStepNode);
                xmlWriter.WriteString(objectSelectionSettings.ZRotationStep.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionRotateAroundCenterNode);
                xmlWriter.WriteString(objectSelectionSettings.RotateAroundSelectionCenter.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionObject2ObjectSnapSettingsNode);

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionObj2ObjSnapEpsNode);
                xmlWriter.WriteString(objectSelectionSettings.Object2ObjectSnapSettings.SnapEps.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(3);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionObj2ObjSnapCanHoverObjectsNode);
                xmlWriter.WriteString(objectSelectionSettings.Object2ObjectSnapSettings.CanHoverObjects.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionAllowPartialOverlapNode);
                xmlWriter.WriteString(objectSelectionSettings.AllowPartialOverlap.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionShapeTypeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionShapeType.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionUpdateModeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionUpdateMode.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionModeNode);
                xmlWriter.WriteString(objectSelectionSettings.SelectionMode.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_ShapePixelWidthNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.SelectionShapeWidthInPixels.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_ShapePixelHeightNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.SelectionShapeHeightInPixels.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(2);
                xmlWriter.WriteStartElement(Octave3DConfigXMLInfo.ObjectSelectionPaint_SizeAdjustmentSpeedScrollWheelNode);
                xmlWriter.WriteString(objectSelectionSettings.PaintModeSettings.ScrollWheelShapeSizeAdjustmentSpeed.ToString());
                xmlWriter.WriteEndElement();

                xmlWriter.WriteNewLine(1);
                xmlWriter.WriteEndElement();
            }
        }