Ejemplo n.º 1
0
        /// <summary>
        /// This method can be called to redo the action.
        /// </summary>
        public void Redo()
        {
            if (_newObjectSelectionMode != _oldObjectSelectionMode)
            {
                // Store data for easy access
                EditorObjectSelection   editorObjectSelection   = EditorObjectSelection.Instance;
                ObjectSelectionSettings objectSelectionSettings = editorObjectSelection.ObjectSelectionSettings;

                // Reactivate the new selection mode
                objectSelectionSettings.ObjectSelectionMode = _newObjectSelectionMode;

                // Send a message to all interested listeners
                ObjectSelectionModeChangedMessage.SendToInterestedListeners(_newObjectSelectionMode);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        public void Execute()
        {
            // Store data for easy access
            EditorObjectSelection   editorObjectSelection   = EditorObjectSelection.Instance;
            ObjectSelectionSettings objectSelectionSettings = editorObjectSelection.ObjectSelectionSettings;

            // Only change the selection mode if it differs from the curent one
            _oldObjectSelectionMode = objectSelectionSettings.ObjectSelectionMode;
            if (_newObjectSelectionMode != _oldObjectSelectionMode)
            {
                // Change the selection mode
                objectSelectionSettings.ObjectSelectionMode = _newObjectSelectionMode;

                // Send a message to all interested listeners
                ObjectSelectionModeChangedMessage.SendToInterestedListeners(_newObjectSelectionMode);

                // Register the action with the Undo/Redo system
                EditorUndoRedoSystem.Instance.RegisterAction(this);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders the selection boxes for the specified selected game objects.
        /// </summary>
        public override void RenderObjectSelectionBoxes(HashSet <GameObject> selectedObjects)
        {
            // Cache needed data
            EditorObjectSelection editorObjectSelecton = EditorObjectSelection.Instance;
            Material lineRenderingMaterial             = MaterialPool.Instance.GLLine;
            ObjectSelectionSettings          objectSelectionSettings          = editorObjectSelecton.ObjectSelectionSettings;
            ObjectSelectionBoxRenderSettings objectSelectionBoxRenderSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings;

            // Create the object selection box calculator instance.
            // Note: This can be null if the user has activated the 'Custom' object selection mode
            //       but hasn't specified a selection box calculator.
            ObjectSelectionBoxCalculator objectSelectionBoxCalculator = ObjectSelectionBoxCalculatorFactory.Create(objectSelectionSettings.ObjectSelectionMode);

            if (objectSelectionBoxCalculator != null)
            {
                // Calculate and retrieve the selection boxes and then render them
                List <ObjectSelectionBox> objectSelectionBoxes = objectSelectionBoxCalculator.CalculateForObjectSelection(selectedObjects);
                GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage,
                                                              EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Renders the selection boxes for the specified selected game objects.
        /// </summary>
        public override void RenderObjectSelectionBoxes(HashSet <GameObject> selectedObjects)
        {
            // Cache needed data
            EditorObjectSelection editorObjectSelecton = EditorObjectSelection.Instance;
            Material lineRenderingMaterial             = MaterialPool.Instance.GLLine;
            ObjectSelectionSettings          objectSelectionSettings          = editorObjectSelecton.ObjectSelectionSettings;
            ObjectSelectionBoxRenderSettings objectSelectionBoxRenderSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings;

            if (objectSelectionBoxRenderSettings.SelectionBoxRenderMode == ObjectSelectionBoxRenderMode.PerObject)
            {
                List <ObjectSelectionBox> objectSelectionBoxes = ObjectSelectionBoxCalculator.CalculatePerObject(selectedObjects);
                GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage,
                                                              EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial);
            }
            else
            if (objectSelectionBoxRenderSettings.SelectionBoxRenderMode == ObjectSelectionBoxRenderMode.FromParentToBottom)
            {
                List <ObjectSelectionBox> objectSelectionBoxes = ObjectSelectionBoxCalculator.CalculateFromParentsToBottom(selectedObjects);
                GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage,
                                                              EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Renders the specified selected objects by rendering a selection box for each game object.
        /// </summary>
        /// <param name="objectSelectionSettings">
        /// Needed to have access to all the settings which are required for the rendering operation.
        /// </param>
        public override void RenderObjectSelection(HashSet <GameObject> selectedObjects, ObjectSelectionSettings objectSelectionSettings)
        {
            // Render the object selection boxes
            ObjectSelectionBoxRenderer objectSelectionBoxRenderer = ObjectSelectionBoxRendererFactory.CreateObjectSelectionBoxDrawer(objectSelectionSettings.ObjectSelectionBoxRenderSettings.SelectionBoxStyle);

            objectSelectionBoxRenderer.RenderObjectSelectionBoxes(selectedObjects);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called when the inspector needs to be rendered.
        /// </summary>
        public override void OnInspectorGUI()
        {
            const int indentLevel = 1;
            Color     newColor;
            ObjectSelectionSettings objectSelectionSettings = _editorObjectSelection.ObjectSelectionSettings;

            bool newBool = EditorGUILayout.ToggleLeft("Can Select Terrain Objects", objectSelectionSettings.CanSelectTerrainObjects);

            if (newBool != objectSelectionSettings.CanSelectTerrainObjects)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.CanSelectTerrainObjects = newBool;
            }

            newBool = EditorGUILayout.ToggleLeft("Can Select Light Objects", objectSelectionSettings.CanSelectLightObjects);
            if (newBool != objectSelectionSettings.CanSelectLightObjects)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.CanSelectLightObjects = newBool;
            }

            newBool = EditorGUILayout.ToggleLeft("Can Select Particle System Objects", objectSelectionSettings.CanSelectParticleSystemObjects);
            if (newBool != objectSelectionSettings.CanSelectParticleSystemObjects)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.CanSelectParticleSystemObjects = newBool;
            }

            newBool = EditorGUILayout.ToggleLeft("Can Select Sprite Objects", objectSelectionSettings.CanSelectSpriteObjects);
            if (newBool != objectSelectionSettings.CanSelectSpriteObjects)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.CanSelectSpriteObjects = newBool;
            }

            newBool = EditorGUILayout.ToggleLeft("Can Select Empty Objects", objectSelectionSettings.CanSelectEmptyObjects);
            if (newBool != objectSelectionSettings.CanSelectEmptyObjects)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.CanSelectEmptyObjects = newBool;
            }

            // Let the user specify the selectable layers
            _selectableLayersListIsVisible = EditorGUILayout.Foldout(_selectableLayersListIsVisible, "Selectable Layers");
            if (_selectableLayersListIsVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Show all available layer names and let the user add/remove layers using toggle buttons
                List <string> allLayerNames = LayerHelper.GetAllLayerNames();
                foreach (string layerName in allLayerNames)
                {
                    int  layerNumber  = LayerMask.NameToLayer(layerName);
                    bool isSelectable = LayerHelper.IsLayerBitSet(objectSelectionSettings.SelectableLayers, layerNumber);

                    newBool = EditorGUILayout.ToggleLeft(layerName, isSelectable);
                    if (newBool != isSelectable)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                        if (isSelectable)
                        {
                            objectSelectionSettings.SelectableLayers = LayerHelper.ClearLayerBit(objectSelectionSettings.SelectableLayers, layerNumber);
                        }
                        else
                        {
                            objectSelectionSettings.SelectableLayers = LayerHelper.SetLayerBit(objectSelectionSettings.SelectableLayers, layerNumber);
                        }
                    }
                }

                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user specify the object selection mode
            EditorGUILayout.Separator();
            ObjectSelectionMode newObjectSelectionMode = (ObjectSelectionMode)EditorGUILayout.EnumPopup("Selection Mode", objectSelectionSettings.ObjectSelectionMode);

            if (newObjectSelectionMode != objectSelectionSettings.ObjectSelectionMode)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.ObjectSelectionMode = newObjectSelectionMode;
            }

            // Let the user specify if any selected objects must be deselected when the selection mechanism is disabled
            bool newBoolValue = EditorGUILayout.ToggleLeft("Deselect Objects When Disabled", objectSelectionSettings.DeselectObjectsWhenDisabled);

            if (newBoolValue != objectSelectionSettings.DeselectObjectsWhenDisabled)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.DeselectObjectsWhenDisabled = newBoolValue;
            }

            // Let the user modify the object selection box render settings
            EditorGUILayout.Separator();
            _objectSelectionBoxRenderSettingsAreVisible = EditorGUILayout.Foldout(_objectSelectionBoxRenderSettingsAreVisible, "Selection Box Render Settings");
            if (_objectSelectionBoxRenderSettingsAreVisible)
            {
                EditorGUI.indentLevel += indentLevel;
                ObjectSelectionBoxRenderSettings objectSelectionBoxDrawSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings;

                newBool = EditorGUILayout.ToggleLeft("Draw Selection Boxes", objectSelectionBoxDrawSettings.DrawBoxes);
                if (newBool != objectSelectionBoxDrawSettings.DrawBoxes)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.DrawBoxes = newBool;
                }

                // Let the user choose the object selection box style
                ObjectSelectionBoxStyle newObjectSelectionBoxStyle = (ObjectSelectionBoxStyle)EditorGUILayout.EnumPopup("Selection Box Style", objectSelectionBoxDrawSettings.SelectionBoxStyle);
                if (newObjectSelectionBoxStyle != objectSelectionBoxDrawSettings.SelectionBoxStyle)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.SelectionBoxStyle = newObjectSelectionBoxStyle;
                }

                // If the object selection box style is set to 'CornerLines', let the user choose the length of the corner lines
                float newFloatValue;
                if (objectSelectionBoxDrawSettings.SelectionBoxStyle == ObjectSelectionBoxStyle.CornerLines)
                {
                    newFloatValue = EditorGUILayout.FloatField("Corner Line Percentage", objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage);
                    if (newFloatValue != objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                        objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage = newFloatValue;
                    }
                }

                // Let the user choose the selection box line color
                Color newColorValue = EditorGUILayout.ColorField("Selection Box Line Color", objectSelectionBoxDrawSettings.SelectionBoxLineColor);
                if (newColorValue != objectSelectionBoxDrawSettings.SelectionBoxLineColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.SelectionBoxLineColor = newColorValue;
                }

                // Let the user choose the selection box size add value
                newFloatValue = EditorGUILayout.FloatField("Selection Box Size Add", objectSelectionBoxDrawSettings.BoxSizeAdd);
                if (newFloatValue != objectSelectionBoxDrawSettings.BoxSizeAdd)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.BoxSizeAdd = newFloatValue;
                }
                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user modify the object selection rectangle render settings
            EditorGUILayout.Separator();
            _objectSelectionRectangleDrawSettingsAreVisible = EditorGUILayout.Foldout(_objectSelectionRectangleDrawSettingsAreVisible, "Selection Rectangle Render Settings");
            if (_objectSelectionRectangleDrawSettingsAreVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Let the user modify the object selection border line color
                ObjectSelectionRectangleRenderSettings objectSelectionRectangleDrawSettings = _editorObjectSelection.ObjectSelectionRectangleRenderSettings;
                newColor = EditorGUILayout.ColorField("Border Line Color", objectSelectionRectangleDrawSettings.BorderLineColor);
                if (newColor != objectSelectionRectangleDrawSettings.BorderLineColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionRectangleDrawSettings.BorderLineColor = newColor;
                }

                // Let the user modify the object selection rectangle fill color
                newColor = EditorGUILayout.ColorField("Fill Color", objectSelectionRectangleDrawSettings.FillColor);
                if (newColor != objectSelectionRectangleDrawSettings.FillColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionRectangleDrawSettings.FillColor = newColor;
                }

                EditorGUI.indentLevel -= indentLevel;
            }
        }
        /// <summary>
        /// Called when the inspector needs to be rendered.
        /// </summary>
        public override void OnInspectorGUI()
        {
            const int indentLevel = 2;
            Color     newColor;
            ObjectSelectionSettings objectSelectionSettings = _editorObjectSelection.ObjectSelectionSettings;

            EditorGUILayout.BeginVertical("Box");

            MultiSelectOverlapMode newOverlapMode = (MultiSelectOverlapMode)EditorGUILayout.EnumPopup("Multi Select Overlap Mode", objectSelectionSettings.MultiSelectOverlapMode);

            if (newOverlapMode != objectSelectionSettings.MultiSelectOverlapMode)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                objectSelectionSettings.MultiSelectOverlapMode = newOverlapMode;
            }

            bool newBool;

            EditorGUI.indentLevel  += 1;
            _restrictionsAreVisible = EditorGUILayout.Foldout(_restrictionsAreVisible, "Restrictions");
            EditorGUI.indentLevel  -= 1;
            if (_restrictionsAreVisible)
            {
                EditorGUI.indentLevel += indentLevel;
                newBool = EditorGUILayout.ToggleLeft("Can Select Terrain Objects", objectSelectionSettings.CanSelectTerrainObjects);
                if (newBool != objectSelectionSettings.CanSelectTerrainObjects)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanSelectTerrainObjects = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Select Light Objects", objectSelectionSettings.CanSelectLightObjects);
                if (newBool != objectSelectionSettings.CanSelectLightObjects)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanSelectLightObjects = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Select Particle System Objects", objectSelectionSettings.CanSelectParticleSystemObjects);
                if (newBool != objectSelectionSettings.CanSelectParticleSystemObjects)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanSelectParticleSystemObjects = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Select Sprite Objects", objectSelectionSettings.CanSelectSpriteObjects);
                if (newBool != objectSelectionSettings.CanSelectSpriteObjects)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanSelectSpriteObjects = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Select Empty Objects", objectSelectionSettings.CanSelectEmptyObjects);
                if (newBool != objectSelectionSettings.CanSelectEmptyObjects)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanSelectEmptyObjects = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Click-Select", objectSelectionSettings.CanClickSelect);
                if (newBool != objectSelectionSettings.CanClickSelect)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanClickSelect = newBool;
                }

                newBool = EditorGUILayout.ToggleLeft("Can Multi-Select", objectSelectionSettings.CanMultiSelect);
                if (newBool != objectSelectionSettings.CanMultiSelect)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.CanMultiSelect = newBool;
                }
                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user specify the selectable layers
            EditorGUI.indentLevel         += 1;
            _selectableLayersListIsVisible = EditorGUILayout.Foldout(_selectableLayersListIsVisible, "Selectable Layers");
            EditorGUI.indentLevel         -= 1;
            if (_selectableLayersListIsVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Show all available layer names and let the user add/remove layers using toggle buttons
                List <string> allLayerNames = LayerHelper.GetAllLayerNames();
                foreach (string layerName in allLayerNames)
                {
                    int  layerNumber  = LayerMask.NameToLayer(layerName);
                    bool isSelectable = LayerHelper.IsLayerBitSet(objectSelectionSettings.SelectableLayers, layerNumber);

                    newBool = EditorGUILayout.ToggleLeft(layerName, isSelectable);
                    if (newBool != isSelectable)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                        if (isSelectable)
                        {
                            objectSelectionSettings.SelectableLayers = LayerHelper.ClearLayerBit(objectSelectionSettings.SelectableLayers, layerNumber);
                        }
                        else
                        {
                            objectSelectionSettings.SelectableLayers = LayerHelper.SetLayerBit(objectSelectionSettings.SelectableLayers, layerNumber);
                        }
                    }
                }

                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user specify the duplicatable layers
            EditorGUI.indentLevel           += 1;
            _duplicatableLayersListIsVisible = EditorGUILayout.Foldout(_duplicatableLayersListIsVisible, "Duplicatable Layers");
            EditorGUI.indentLevel           -= 1;
            if (_duplicatableLayersListIsVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Show all available layer names and let the user add/remove layers using toggle buttons
                List <string> allLayerNames = LayerHelper.GetAllLayerNames();
                foreach (string layerName in allLayerNames)
                {
                    int  layerNumber    = LayerMask.NameToLayer(layerName);
                    bool isDuplicatable = LayerHelper.IsLayerBitSet(objectSelectionSettings.DuplicatableLayers, layerNumber);

                    newBool = EditorGUILayout.ToggleLeft(layerName, isDuplicatable);
                    if (newBool != isDuplicatable)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                        if (isDuplicatable)
                        {
                            objectSelectionSettings.DuplicatableLayers = LayerHelper.ClearLayerBit(objectSelectionSettings.DuplicatableLayers, layerNumber);
                        }
                        else
                        {
                            objectSelectionSettings.DuplicatableLayers = LayerHelper.SetLayerBit(objectSelectionSettings.DuplicatableLayers, layerNumber);
                        }
                    }
                }

                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user modify the object selection box render settings
            EditorGUI.indentLevel += 1;
            _objectSelectionBoxRenderSettingsAreVisible = EditorGUILayout.Foldout(_objectSelectionBoxRenderSettingsAreVisible, "Selection Box Render Settings");
            EditorGUI.indentLevel -= 1;
            if (_objectSelectionBoxRenderSettingsAreVisible)
            {
                EditorGUI.indentLevel += indentLevel;
                ObjectSelectionBoxRenderSettings objectSelectionBoxDrawSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings;

                newBool = EditorGUILayout.ToggleLeft("Draw Selection Boxes", objectSelectionBoxDrawSettings.DrawBoxes);
                if (newBool != objectSelectionBoxDrawSettings.DrawBoxes)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.DrawBoxes = newBool;
                }

                // Let the user choose the object selection box style
                ObjectSelectionBoxStyle newObjectSelectionBoxStyle = (ObjectSelectionBoxStyle)EditorGUILayout.EnumPopup("Selection Box Style", objectSelectionBoxDrawSettings.SelectionBoxStyle);
                if (newObjectSelectionBoxStyle != objectSelectionBoxDrawSettings.SelectionBoxStyle)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.SelectionBoxStyle = newObjectSelectionBoxStyle;
                }

                ObjectSelectionBoxRenderMode newObjSelBoxRenderMode = (ObjectSelectionBoxRenderMode)EditorGUILayout.EnumPopup("Selection Box Render Mode", objectSelectionBoxDrawSettings.SelectionBoxRenderMode);
                if (newObjSelBoxRenderMode != objectSelectionBoxDrawSettings.SelectionBoxRenderMode)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.SelectionBoxRenderMode = newObjSelBoxRenderMode;
                }

                // If the object selection box style is set to 'CornerLines', let the user choose the length of the corner lines
                float newFloatValue;
                if (objectSelectionBoxDrawSettings.SelectionBoxStyle == ObjectSelectionBoxStyle.CornerLines)
                {
                    newFloatValue = EditorGUILayout.FloatField("Corner Line Percentage", objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage);
                    if (newFloatValue != objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                        objectSelectionBoxDrawSettings.SelectionBoxCornerLinePercentage = newFloatValue;
                    }
                }

                // Let the user choose the selection box line color
                Color newColorValue = EditorGUILayout.ColorField("Selection Box Line Color", objectSelectionBoxDrawSettings.SelectionBoxLineColor);
                if (newColorValue != objectSelectionBoxDrawSettings.SelectionBoxLineColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.SelectionBoxLineColor = newColorValue;
                }

                // Let the user choose the selection box size add value
                newFloatValue = EditorGUILayout.FloatField("Selection Box Size Add", objectSelectionBoxDrawSettings.BoxSizeAdd);
                if (newFloatValue != objectSelectionBoxDrawSettings.BoxSizeAdd)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionBoxDrawSettings.BoxSizeAdd = newFloatValue;
                }
                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user modify the object selection rectangle render settings
            EditorGUI.indentLevel += 1;
            _objectSelectionRectangleDrawSettingsAreVisible = EditorGUILayout.Foldout(_objectSelectionRectangleDrawSettingsAreVisible, "Selection Rectangle Render Settings");
            EditorGUI.indentLevel -= 1;
            if (_objectSelectionRectangleDrawSettingsAreVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Let the user modify the object selection border line color
                ObjectSelectionRectangleRenderSettings objectSelectionRectangleDrawSettings = _editorObjectSelection.ObjectSelectionRectangleRenderSettings;
                newColor = EditorGUILayout.ColorField("Border Line Color", objectSelectionRectangleDrawSettings.BorderLineColor);
                if (newColor != objectSelectionRectangleDrawSettings.BorderLineColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionRectangleDrawSettings.BorderLineColor = newColor;
                }

                // Let the user modify the object selection rectangle fill color
                newColor = EditorGUILayout.ColorField("Fill Color", objectSelectionRectangleDrawSettings.FillColor);
                if (newColor != objectSelectionRectangleDrawSettings.FillColor)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionRectangleDrawSettings.FillColor = newColor;
                }

                EditorGUI.indentLevel -= indentLevel;
            }

            // Let the user specify the root object for select all
            EditorGUI.indentLevel         += 1;
            _selectableLayersListIsVisible = EditorGUILayout.Foldout(_selectableLayersListIsVisible, "'Select All' Root Object");
            EditorGUI.indentLevel         -= 1;
            if (_selectableLayersListIsVisible)
            {
                EditorGUI.indentLevel += indentLevel;

                // Let the user select a parent object for select all
                GameObject selectAllParent = EditorGUILayout.ObjectField("Select All Root Object", objectSelectionSettings.SelectAllRoot, typeof(GameObject), true) as GameObject;
                if (selectAllParent != objectSelectionSettings.SelectAllRoot)
                {
                    UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorObjectSelection);
                    objectSelectionSettings.SelectAllRoot = selectAllParent;
                }
                EditorGUI.indentLevel -= indentLevel;
            }


            EditorGUILayout.EndVertical();

            _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings");
            if (_keyMappingsAreVisible)
            {
                _editorObjectSelection.AppendToSelectionShortcut.RenderView(_editorObjectSelection);
                _editorObjectSelection.MultiDeselectShortcut.RenderView(_editorObjectSelection);
                _editorObjectSelection.DuplicateSelectionShortcut.RenderView(_editorObjectSelection);
                _editorObjectSelection.DeleteSelectionShortcut.RenderView(_editorObjectSelection);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Renders the specified object selection. The second parameter holds the object
 /// selection settings which are needed to perform the rendering operation.
 /// </summary>
 public abstract void RenderObjectSelection(HashSet <GameObject> selectedObjects, ObjectSelectionSettings objectSelectionSettings);