Example #1
0
        /// <summary>
        /// Called when the inspector needs to be rendered.
        /// </summary>
        public override void OnInspectorGUI()
        {
            bool newBool;

            // Draw the common gizmo properties
            base.OnInspectorGUI();

            EditorGUILayout.BeginVertical("Box");

            // Let the user control the gizmo axis length
            float newFloatValue = EditorGUILayout.FloatField("Axis Length", _translationGizmo.AxisLength);

            if (newFloatValue != _translationGizmo.AxisLength)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.AxisLength = newFloatValue;
            }

            // Let the user control the radius of the arrow cones which sit at the tip of each axis
            newFloatValue = EditorGUILayout.FloatField("Arrow Cone Radius", _translationGizmo.ArrowConeRadius);
            if (newFloatValue != _translationGizmo.ArrowConeRadius)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.ArrowConeRadius = newFloatValue;
            }

            // Let the user control the length of the arrow cones which sit at the tip of each axis
            newFloatValue = EditorGUILayout.FloatField("Arrow Cone Length", _translationGizmo.ArrowConeLength);
            if (newFloatValue != _translationGizmo.ArrowConeLength)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.ArrowConeLength = newFloatValue;
            }

            // Let the user specify whether or not the arrow cones must be lit
            bool newBoolValue = EditorGUILayout.ToggleLeft("Are Arrow Cones Lit", _translationGizmo.AreArrowConesLit);

            if (newBoolValue != _translationGizmo.AreArrowConesLit)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.AreArrowConesLit = newBoolValue;
            }

            EditorGUILayout.Separator();
            newFloatValue = EditorGUILayout.FloatField("Multi Axis Square Alpha", _translationGizmo.MultiAxisSquareAlpha);
            if (newFloatValue != _translationGizmo.MultiAxisSquareAlpha)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.MultiAxisSquareAlpha = newFloatValue;
            }

            // Let the user change the multi-axis square size
            newFloatValue = EditorGUILayout.FloatField("Multi Axis Square Size", _translationGizmo.MultiAxisSquareSize);
            if (newFloatValue != _translationGizmo.MultiAxisSquareSize)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.MultiAxisSquareSize = newFloatValue;
            }

            // Let the user specify whether or not the mulit-axis squares must be adjusted during runtime for better visibility
            newBoolValue = EditorGUILayout.ToggleLeft("Adjust Multi Axis For Better Visibility", _translationGizmo.AdjustMultiAxisForBetterVisibility);
            if (newBoolValue != _translationGizmo.AdjustMultiAxisForBetterVisibility)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.AdjustMultiAxisForBetterVisibility = newBoolValue;
            }

            // Let the user specify the special op square line color
            EditorGUILayout.Separator();
            Color newColorValue = EditorGUILayout.ColorField("Color Of Special Op Square", _translationGizmo.SpecialOpSquareColor);

            if (newColorValue != _translationGizmo.SpecialOpSquareColor)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.SpecialOpSquareColor = newColorValue;
            }

            // Let the user specify the special op square line color when the square is selected
            newColorValue = EditorGUILayout.ColorField("Color Of Special Op Square (Selected)", _translationGizmo.SpecialOpSquareColorWhenSelected);
            if (newColorValue != _translationGizmo.SpecialOpSquareColorWhenSelected)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.SpecialOpSquareColorWhenSelected = newColorValue;
            }

            // Let the user specify the screen size of the special op square
            newFloatValue = EditorGUILayout.FloatField("Screen Size Of Special Op Square", _translationGizmo.ScreenSizeOfSpecialOpSquare);
            if (newFloatValue != _translationGizmo.ScreenSizeOfSpecialOpSquare)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.ScreenSizeOfSpecialOpSquare = newFloatValue;
            }

            // Let the user specify the snap step value
            EditorGUILayout.Separator();
            newFloatValue = EditorGUILayout.FloatField("Snap Step Value (In World Units)", _translationGizmo.SnapSettings.StepValueInWorldUnits);
            if (newFloatValue != _translationGizmo.SnapSettings.StepValueInWorldUnits)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.SnapSettings.StepValueInWorldUnits = newFloatValue;
            }

            newFloatValue = EditorGUILayout.FloatField("Move Scale (When active)", _translationGizmo.MoveScale);
            if (newFloatValue != _translationGizmo.MoveScale)
            {
                UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                _translationGizmo.MoveScale = newFloatValue;
            }
            EditorGUILayout.EndVertical();

            RenderLayerMaskControls();
            EditorGUI.indentLevel   += 1;
            _vertexSnapLayersVisible = EditorGUILayout.Foldout(_vertexSnapLayersVisible, "Vertex Snap Layers");
            EditorGUI.indentLevel   -= 1;
            if (_vertexSnapLayersVisible)
            {
                EditorGUILayout.BeginVertical("Box");
                List <string> allLayerNames = LayerHelper.GetAllLayerNames();
                foreach (string layerName in allLayerNames)
                {
                    int  layerNumber = LayerMask.NameToLayer(layerName);
                    bool isBitSet    = _translationGizmo.IsVertexSnapLayerBitSet(layerNumber);

                    newBool = EditorGUILayout.ToggleLeft(layerName, isBitSet);
                    if (newBool != isBitSet)
                    {
                        UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_translationGizmo);
                        if (isBitSet)
                        {
                            _translationGizmo.SetVertexSnapLayerBit(layerNumber, false);
                        }
                        else
                        {
                            _translationGizmo.SetVertexSnapLayerBit(layerNumber, true);
                        }
                    }
                }

                EditorGUILayout.EndVertical();
            }

            _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings");
            if (_keyMappingsAreVisible)
            {
                _translationGizmo.TranslateAlongScreenAxesShortcut.RenderView(_translationGizmo);
                _translationGizmo.EnableStepSnappingShortcut.RenderView(_translationGizmo);
                _translationGizmo.EnableVertexSnappingShortcut.RenderView(_translationGizmo);
                _translationGizmo.EnableBoxSnappingShortcut.RenderView(_translationGizmo);
                _translationGizmo.EnableSurfacePlacementWithXAlignment.RenderView(_translationGizmo);
                _translationGizmo.EnableSurfacePlacementWithYAlignment.RenderView(_translationGizmo);
                _translationGizmo.EnableSurfacePlacementWithZAlignment.RenderView(_translationGizmo);
                _translationGizmo.EnableSurfacePlacementWithNoAxisAlignment.RenderView(_translationGizmo);
                _translationGizmo.EnableMoveScale.RenderView(_translationGizmo);
            }

            // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view
            SceneView.RepaintAll();
        }
Example #2
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);
            }
        }
Example #4
0
 /// <summary>
 /// Can be used to check if the specified layer is masked. Objects which belong to masked layers
 /// can not be manipulated by the gizmo.
 /// </summary>
 public bool IsObjectLayerMasked(int objectLayer)
 {
     return(LayerHelper.IsLayerBitSet(_maskedObjectLayers, objectLayer));
 }
Example #5
0
 /// <summary>
 /// Unmasks the specified object layer.
 /// </summary>
 public void UnmaskObjectkLayer(int objectLayer)
 {
     _maskedObjectLayers = LayerHelper.ClearLayerBit(_maskedObjectLayers, objectLayer);
 }
Example #6
0
 /// <summary>
 /// Masks the specified object layer. Objects which belong to masked layers can not be
 /// manipulated by the gizmo.
 /// </summary>
 public void MaskObjectLayer(int objectLayer)
 {
     _maskedObjectLayers = LayerHelper.SetLayerBit(_maskedObjectLayers, objectLayer);
 }