/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { Vector3 newVec3 = EditorGUILayout.Vector3Field("Light Object Volume Size", _editorApplication.VolumeSizeForLightObjects); if (newVec3 != _editorApplication.VolumeSizeForLightObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForLightObjects = newVec3; } newVec3 = EditorGUILayout.Vector3Field("Particle System Object Volume Size", _editorApplication.VolumeSizeForParticleSystemObjects); if (newVec3 != _editorApplication.VolumeSizeForParticleSystemObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForParticleSystemObjects = newVec3; } newVec3 = EditorGUILayout.Vector3Field("Empty Object Volume Size", _editorApplication.VolumeSizeForEmptyObjects); if (newVec3 != _editorApplication.VolumeSizeForEmptyObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForEmptyObjects = newVec3; } _xzGridSetingsAreVisible = EditorGUILayout.Foldout(_xzGridSetingsAreVisible, "XZ Grid Settings"); if (_xzGridSetingsAreVisible) { EditorGUI.indentLevel += 1; _editorApplication.XZGrid.RenderView(_editorApplication); EditorGUI.indentLevel -= 1; } }
public void RenderView(MonoBehaviour parentMono) { bool newBool = EditorGUILayout.ToggleLeft("Is Visible", _isVisible); if (newBool != _isVisible) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _isVisible = newBool; } Color newColor = EditorGUILayout.ColorField("Line Color", _lineColor); if (newColor != _lineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lineColor = newColor; } float newFloat = EditorGUILayout.FloatField("Cell Size X", CellSizeX); if (newFloat != CellSizeX) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); CellSizeX = newFloat; } newFloat = EditorGUILayout.FloatField("Cell Size Z", CellSizeZ); if (newFloat != CellSizeZ) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); CellSizeZ = newFloat; } }
public void RenderView(MonoBehaviour parentMono) { bool newBool = EditorGUILayout.ToggleLeft("Is Visible", IsVisible); if (newBool != _isVisible) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); IsVisible = newBool; } Color newColor = EditorGUILayout.ColorField("Top Color", _topColor); if (newColor != _topColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _topColor = newColor; } newColor = EditorGUILayout.ColorField("Bottom Color", _bottomColor); if (newColor != _bottomColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _bottomColor = newColor; } float newFloat = EditorGUILayout.FloatField("Gradient Offset", GradientOffset); if (newFloat != GradientOffset) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); GradientOffset = newFloat; } }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { // Let the user specify the maximum number of actions which can be registered with the Undo/redo system int newInt = EditorGUILayout.IntField("Action Limit", _editorUndoRedoSystem.ActionLimit); if (newInt != _editorUndoRedoSystem.ActionLimit) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorUndoRedoSystem); _editorUndoRedoSystem.ActionLimit = newInt; } }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { // Inform the user that some gizmo properties can only be verified during runtime EditorGUILayout.Separator(); EditorGUILayout.LabelField("Note: Properties prefixed by \'" + _runtimeOnlyPropertyPrefix + "\' can only be verified at runtime.", EditorGUIStyles.GetInformativeLabelStyle()); // Allow the user to specify the gizmo base scale float newFloatValue = EditorGUILayout.FloatField("Gizmo Base Scale", _gizmo.GizmoBaseScale); if (newFloatValue != _gizmo.GizmoBaseScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.GizmoBaseScale = newFloatValue; } // Allow the user to specify if whether or not the size of the gizmo must be preserved in screen space bool newBoolValue = EditorGUILayout.Toggle(_runtimeOnlyPropertyPrefix + "Preserve Gizmo Screen Size", _gizmo.PreserveGizmoScreenSize); if (newBoolValue != _gizmo.PreserveGizmoScreenSize) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.PreserveGizmoScreenSize = newBoolValue; } // Loop through each axis and let the user modify their colors EditorGUILayout.Separator(); for (int axisIndex = 0; axisIndex < 3; ++axisIndex) { // Construct the text used to draw the axis label string axisLabelText = ((GizmoAxis)axisIndex).ToString() + " Axis Color"; // Allow the user to change the color Color currentAxisColor = _gizmo.GetAxisColor((GizmoAxis)axisIndex); Color newAxisColor = EditorGUILayout.ColorField(axisLabelText, currentAxisColor); if (newAxisColor != currentAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.SetAxisColor((GizmoAxis)axisIndex, newAxisColor); } } // Allow the user to choose the color which must be used to draw the currently selected axis Color newColorValue = EditorGUILayout.ColorField(_runtimeOnlyPropertyPrefix + "Selected Axis Color", _gizmo.SelectedAxisColor); if (newColorValue != _gizmo.SelectedAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.SelectedAxisColor = newColorValue; } // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view SceneView.RepaintAll(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.BeginVertical("Box"); Color newColor = EditorGUILayout.ColorField("Line Color", _volumeScaleGizmo.LineColor); if (newColor != _volumeScaleGizmo.LineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_volumeScaleGizmo); _volumeScaleGizmo.LineColor = newColor; } int newInt = EditorGUILayout.IntField("Drag Handle Size (in pixels)", _volumeScaleGizmo.DragHandleSizeInPixels); if (newInt != _volumeScaleGizmo.DragHandleSizeInPixels) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_volumeScaleGizmo); _volumeScaleGizmo.DragHandleSizeInPixels = newInt; } EditorGUILayout.Separator(); float newFloat = EditorGUILayout.FloatField("Snap Step (In World Units)", _volumeScaleGizmo.SnapStepInWorldUnits); if (newFloat != _volumeScaleGizmo.SnapStepInWorldUnits) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_volumeScaleGizmo); _volumeScaleGizmo.SnapStepInWorldUnits = newFloat; } EditorGUILayout.EndVertical(); _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _volumeScaleGizmo.EnableScaleFromCenterShortcut.RenderView(_volumeScaleGizmo); _volumeScaleGizmo.EnableStepSnappingShortcut.RenderView(_volumeScaleGizmo); } }
protected void RenderLayerMaskControls() { bool newBool; // Let the user specify which layers can be transformed by the gizmo EditorGUI.indentLevel += 1; _transformableLayersListIsVisible = EditorGUILayout.Foldout(_transformableLayersListIsVisible, "Transformable Layers"); EditorGUI.indentLevel -= 1; if (_transformableLayersListIsVisible) { EditorGUILayout.BeginVertical("Box"); // 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 isTransformable = !_gizmo.IsObjectLayerMasked(layerNumber); newBool = EditorGUILayout.ToggleLeft(layerName, isTransformable); if (newBool != isTransformable) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); if (isTransformable) { _gizmo.MaskObjectLayer(layerNumber); } else { _gizmo.UnmaskObjectkLayer(layerNumber); } } } EditorGUILayout.EndVertical(); } }
/// <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() { // Let the user specify the translation gizmo EditorGUILayout.BeginVertical("Box"); TranslationGizmo translationGizmo = EditorGUILayout.ObjectField("Translation Gizmo", _gizmoSystem.TranslationGizmo, typeof(TranslationGizmo), true) as TranslationGizmo; if (translationGizmo != _gizmoSystem.TranslationGizmo) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); _gizmoSystem.TranslationGizmo = translationGizmo; } // Let the user specify the rotation gizmo RotationGizmo rotationGizmo = EditorGUILayout.ObjectField("Rotation Gizmo", _gizmoSystem.RotationGizmo, typeof(RotationGizmo), true) as RotationGizmo; if (rotationGizmo != _gizmoSystem.RotationGizmo) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); _gizmoSystem.RotationGizmo = rotationGizmo; } // Let the user specify the scale gizmo ScaleGizmo scaleGizmo = EditorGUILayout.ObjectField("Scale Gizmo", _gizmoSystem.ScaleGizmo, typeof(ScaleGizmo), true) as ScaleGizmo; if (scaleGizmo != _gizmoSystem.ScaleGizmo) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); _gizmoSystem.ScaleGizmo = scaleGizmo; } VolumeScaleGizmo volumeScaleGizmo = EditorGUILayout.ObjectField("Volume Scale Gizmo", _gizmoSystem.VolumeScaleGizmo, typeof(VolumeScaleGizmo), true) as VolumeScaleGizmo; if (scaleGizmo != _gizmoSystem.VolumeScaleGizmo) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); _gizmoSystem.VolumeScaleGizmo = volumeScaleGizmo; } // Let the user specify the active gimo type if (_gizmoSystem.IsAnyGizmoTypeAvailable()) { EditorGUILayout.Separator(); GizmoType newActiveGizmoType = (GizmoType)EditorGUILayout.EnumPopup("Active Gizmo Type", _gizmoSystem.ActiveGizmoType); if (newActiveGizmoType != _gizmoSystem.ActiveGizmoType) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); _gizmoSystem.ActiveGizmoType = newActiveGizmoType; } } EditorGUILayout.Separator(); List <GizmoType> allGizmoTypes = Enum.GetValues(typeof(GizmoType)).Cast <GizmoType>().ToList(); foreach (var gizmoType in allGizmoTypes) { bool isGizmoTypeAvailable = _gizmoSystem.IsGizmoTypeAvailable(gizmoType); bool newBool = EditorGUILayout.ToggleLeft(gizmoType.ToString(), isGizmoTypeAvailable); if (isGizmoTypeAvailable != newBool) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmoSystem); if (newBool) { _gizmoSystem.SetGizmoTypeAvailable(gizmoType, true); } else { _gizmoSystem.SetGizmoTypeAvailable(gizmoType, false); } } } EditorGUILayout.EndVertical(); _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _gizmoSystem.ActivateTranslationGizmoShortcut.RenderView(_gizmoSystem); _gizmoSystem.ActivateRotationGizmoShortcut.RenderView(_gizmoSystem); _gizmoSystem.ActivateScaleGizmoShortcut.RenderView(_gizmoSystem); _gizmoSystem.ActivateVolumeScaleGizmoShortcut.RenderView(_gizmoSystem); _gizmoSystem.ActivateGlobalTransformShortcut.RenderView(_gizmoSystem); _gizmoSystem.ActivateLocalTransformShortcut.RenderView(_gizmoSystem); _gizmoSystem.TurnOffGizmosShortcut.RenderView(_gizmoSystem); _gizmoSystem.TogglePivotShortcut.RenderView(_gizmoSystem); } }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { float newFloatValue; bool newBoolValue; EditorGUILayout.BeginVertical("Box"); // Allow the user to specify the gizmo base scale if (_gizmo.GetGizmoType() != GizmoType.VolumeScale) { newFloatValue = EditorGUILayout.FloatField("Gizmo Base Scale", _gizmo.GizmoBaseScale); if (newFloatValue != _gizmo.GizmoBaseScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.GizmoBaseScale = newFloatValue; } // Allow the user to specify if whether or not the size of the gizmo must be preserved in screen space newBoolValue = EditorGUILayout.ToggleLeft("Preserve Gizmo Screen Size", _gizmo.PreserveGizmoScreenSize); if (newBoolValue != _gizmo.PreserveGizmoScreenSize) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.PreserveGizmoScreenSize = newBoolValue; } EditorGUILayout.Separator(); } // Loop through each axis and let the user modify their colors for (int axisIndex = 0; axisIndex < 3; ++axisIndex) { // Construct the text used to draw the axis label string axisLabelText = ((GizmoAxis)axisIndex).ToString() + " Axis Color"; // Allow the user to change the color Color currentAxisColor = _gizmo.GetAxisColor((GizmoAxis)axisIndex); Color newAxisColor = EditorGUILayout.ColorField(axisLabelText, currentAxisColor); if (newAxisColor != currentAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.SetAxisColor((GizmoAxis)axisIndex, newAxisColor); } } // Allow the user to choose the color which must be used to draw the currently selected axis Color newColorValue = EditorGUILayout.ColorField("Selected Axis Color", _gizmo.SelectedAxisColor); if (newColorValue != _gizmo.SelectedAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.SelectedAxisColor = newColorValue; } EditorGUILayout.BeginHorizontal(); string[] axesLabels = new string[] { "X", "Y", "Z" }; for (int axisIndex = 0; axisIndex < 3; ++axisIndex) { bool isAxisVisible = _gizmo.GetAxisVisibility(axisIndex); newBoolValue = EditorGUILayout.ToggleLeft("Show " + axesLabels[axisIndex] + " Axis", isAxisVisible, GUILayout.Width(90.0f)); if (newBoolValue != isAxisVisible) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_gizmo); _gizmo.SetAxisVisibility(newBoolValue, axisIndex); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view SceneView.RepaintAll(); }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { EditorGUILayout.BeginVertical("Box"); bool newBool = EditorGUILayout.ToggleLeft("Enable Undo/Redo", _editorApplication.EnableUndoRedo); if (newBool != _editorApplication.EnableUndoRedo) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.EnableUndoRedo = newBool; } newBool = EditorGUILayout.ToggleLeft("Use Custom Camera", _editorApplication.UseCustomCamera); if (newBool != _editorApplication.UseCustomCamera) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.UseCustomCamera = newBool; } if (_editorApplication.UseCustomCamera) { Camera newCam = EditorGUILayout.ObjectField("Custom Camera", _editorApplication.CustomCamera, typeof(Camera), true) as Camera; if (newCam != _editorApplication.CustomCamera) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.CustomCamera = newCam; } } if (_editorApplication.UseUnityColliders) { EditorGUILayout.HelpBox("Interacting with 2D sprites is not possible when this option is checked. " + "Uncheck this if you need to select and manipulate 2D sprites. You should only use Unity Colliders when you are experiencing low frame rates which " + "can happen when working with really high res meshes.", UnityEditor.MessageType.Info); } newBool = EditorGUILayout.ToggleLeft("Use Unity Colliders", _editorApplication.UseUnityColliders); if (newBool != _editorApplication.UseUnityColliders) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.UseUnityColliders = newBool; } if (!_editorApplication.UseUnityColliders) { Vector3 newVec3 = EditorGUILayout.Vector3Field("Light Object Volume Size", _editorApplication.VolumeSizeForLightObjects); if (newVec3 != _editorApplication.VolumeSizeForLightObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForLightObjects = newVec3; } newVec3 = EditorGUILayout.Vector3Field("Particle System Object Volume Size", _editorApplication.VolumeSizeForParticleSystemObjects); if (newVec3 != _editorApplication.VolumeSizeForParticleSystemObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForParticleSystemObjects = newVec3; } newVec3 = EditorGUILayout.Vector3Field("Empty Object Volume Size", _editorApplication.VolumeSizeForEmptyObjects); if (newVec3 != _editorApplication.VolumeSizeForEmptyObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorApplication); _editorApplication.VolumeSizeForEmptyObjects = newVec3; } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel += 1; EditorGUILayout.BeginVertical("Box"); _xzGridSetingsAreVisible = EditorGUILayout.Foldout(_xzGridSetingsAreVisible, "XZ Grid Settings"); if (_xzGridSetingsAreVisible) { EditorGUI.indentLevel += 1; _editorApplication.XZGrid.RenderView(_editorApplication); EditorGUI.indentLevel -= 1; } EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= 1; _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _editorApplication.ScrollGridUpDownShortcut.RenderView(_editorApplication); _editorApplication.ScrollGridUpDownStepShortcut.RenderView(_editorApplication); } }
public override void OnInspectorGUI() { EditorGUILayout.BeginVertical("Box"); SceneGizmoCorner newCorner = (SceneGizmoCorner)EditorGUILayout.EnumPopup("Corner", _sceneGizmo.Corner); if (newCorner != _sceneGizmo.Corner) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.Corner = newCorner; } Color newColor = EditorGUILayout.ColorField("X Axis Clolor", _sceneGizmo.XAxisColor); if (newColor != _sceneGizmo.XAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.XAxisColor = newColor; } newColor = EditorGUILayout.ColorField("Y Axis Clolor", _sceneGizmo.YAxisColor); if (newColor != _sceneGizmo.YAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.YAxisColor = newColor; } newColor = EditorGUILayout.ColorField("Z Axis Clolor", _sceneGizmo.ZAxisColor); if (newColor != _sceneGizmo.ZAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.ZAxisColor = newColor; } newColor = EditorGUILayout.ColorField("Negative Axis Color", _sceneGizmo.NegativeAxisColor); if (newColor != _sceneGizmo.NegativeAxisColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.NegativeAxisColor = newColor; } newColor = EditorGUILayout.ColorField("Cube Color", _sceneGizmo.CubeColor); if (newColor != _sceneGizmo.CubeColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.CubeColor = newColor; } newColor = EditorGUILayout.ColorField("Hovered Component Color", _sceneGizmo.HoveredComponentColor); if (newColor != _sceneGizmo.HoveredComponentColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.HoveredComponentColor = newColor; } float newFloat = EditorGUILayout.FloatField("Camera Look Align Duration (seconds)", _sceneGizmo.CameraAlignDuration); if (newFloat != _sceneGizmo.CameraAlignDuration) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_sceneGizmo); _sceneGizmo.CameraAlignDuration = newFloat; } EditorGUILayout.EndVertical(); }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { // Draw the common gizmo properties base.OnInspectorGUI(); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); bool newBoolValue = EditorGUILayout.ToggleLeft("Full Circle X", _rotationGizmo.ShowFullRotationCircleX, GUILayout.Width(90.0f)); if (newBoolValue != _rotationGizmo.ShowFullRotationCircleX) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowFullRotationCircleX = newBoolValue; } newBoolValue = EditorGUILayout.ToggleLeft("Full Circle Y", _rotationGizmo.ShowFullRotationCircleY, GUILayout.Width(90.0f)); if (newBoolValue != _rotationGizmo.ShowFullRotationCircleY) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowFullRotationCircleY = newBoolValue; } newBoolValue = EditorGUILayout.ToggleLeft("Full Circle Z", _rotationGizmo.ShowFullRotationCircleZ, GUILayout.Width(90.0f)); if (newBoolValue != _rotationGizmo.ShowFullRotationCircleZ) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowFullRotationCircleZ = newBoolValue; } EditorGUILayout.EndHorizontal(); // Let the user change the rotation sphere radius EditorGUILayout.Separator(); float newFloatValue = EditorGUILayout.FloatField("Rotation Sphere Radius", _rotationGizmo.RotationSphereRadius); if (newFloatValue != _rotationGizmo.RotationSphereRadius) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationSphereRadius = newFloatValue; } // Let the user change the rotation sphere color Color newColorValue = EditorGUILayout.ColorField("Rotation Sphere Color", _rotationGizmo.RotationSphereColor); if (newColorValue != _rotationGizmo.RotationSphereColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationSphereColor = newColorValue; } // Let the user specify whether or not the rotation sphere must be lit newBoolValue = EditorGUILayout.ToggleLeft("Is Rotation Sphere Lit", _rotationGizmo.IsRotationSphereLit); if (newBoolValue != _rotationGizmo.IsRotationSphereLit) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.IsRotationSphereLit = newBoolValue; } // Let the user control the visibility of the rotation guide EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.ToggleLeft("Show Rotation Guide", _rotationGizmo.ShowRotationGuide); if (newBoolValue != _rotationGizmo.ShowRotationGuide) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowRotationGuide = newBoolValue; } // Let the user control the rotation guide line color newColorValue = EditorGUILayout.ColorField("Rotation Guide Line Color", _rotationGizmo.RotationGuieLineColor); if (newColorValue != _rotationGizmo.RotationGuieLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationGuieLineColor = newColorValue; } // Let the user control the color of the rotation guide disc newColorValue = EditorGUILayout.ColorField("Rotation Guide Disc Color", _rotationGizmo.RotationGuideDiscColor); if (newColorValue != _rotationGizmo.RotationGuideDiscColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationGuideDiscColor = newColorValue; } // Let the user control the visibility of the rotation sphere boundary EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.ToggleLeft("Show Rotation Sphere", _rotationGizmo.ShowRotationSphere); if (newBoolValue != _rotationGizmo.ShowRotationSphere) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowRotationSphere = newBoolValue; } newBoolValue = EditorGUILayout.ToggleLeft("Show Rotation Sphere Boundary", _rotationGizmo.ShowSphereBoundary); if (newBoolValue != _rotationGizmo.ShowSphereBoundary) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowSphereBoundary = newBoolValue; } // Let the user control the rotation sphere boundary line color newColorValue = EditorGUILayout.ColorField("Rotation Sphere Boundary Line Color", _rotationGizmo.SphereBoundaryLineColor); if (newColorValue != _rotationGizmo.SphereBoundaryLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.SphereBoundaryLineColor = newColorValue; } // Let the user control the visibility of the camera look rotation circle EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.ToggleLeft("Show Camera Look Rotation Circle", _rotationGizmo.ShowCameraLookRotationCircle); if (newBoolValue != _rotationGizmo.ShowCameraLookRotationCircle) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowCameraLookRotationCircle = newBoolValue; } // Let the user control the camera look rotation circle scale newFloatValue = EditorGUILayout.FloatField("Camera Look Rotation Circle Radius Scale", _rotationGizmo.CameraLookRotationCircleRadiusScale); if (newFloatValue != _rotationGizmo.CameraLookRotationCircleRadiusScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleRadiusScale = newFloatValue; } // Let the user control the camera look rotation circle line color newColorValue = EditorGUILayout.ColorField("Camera Look Rotation Circle Line Color", _rotationGizmo.CameraLookRotationCircleLineColor); if (newColorValue != _rotationGizmo.SphereBoundaryLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleLineColor = newColorValue; } // Let the user control the color of the camera look rotation circle when it is selected newColorValue = EditorGUILayout.ColorField("Camera Look Rotation Circle Color (Selected)", _rotationGizmo.CameraLookRotationCircleColorWhenSelected); if (newColorValue != _rotationGizmo.CameraLookRotationCircleColorWhenSelected) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleColorWhenSelected = newColorValue; } // Let the user specify the snap step value EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Snap Step Value (In Degrees)", _rotationGizmo.SnapSettings.StepValueInDegrees); if (newFloatValue != _rotationGizmo.SnapSettings.StepValueInDegrees) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.SnapSettings.StepValueInDegrees = newFloatValue; } EditorGUILayout.EndVertical(); RenderLayerMaskControls(); _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _rotationGizmo.EnableStepSnappingShortcut.RenderView(_rotationGizmo); } // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view SceneView.RepaintAll(); }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { // Draw the common gizmo properties base.OnInspectorGUI(); // Let the user change the rotation sphere radius EditorGUILayout.Separator(); float newFloatValue = EditorGUILayout.FloatField("Rotation Sphere Radius", _rotationGizmo.RotationSphereRadius); if (newFloatValue != _rotationGizmo.RotationSphereRadius) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationSphereRadius = newFloatValue; } // Let the user change the rotation sphere color Color newColorValue = EditorGUILayout.ColorField("Rotation Sphere Color", _rotationGizmo.RotationSphereColor); if (newColorValue != _rotationGizmo.RotationSphereColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationSphereColor = newColorValue; } // Let the user specify whether or not the rotation sphere must be lit bool newBoolValue = EditorGUILayout.Toggle(_runtimeOnlyPropertyPrefix + "Is Rotation Sphere Lit", _rotationGizmo.IsRotationSphereLit); if (newBoolValue != _rotationGizmo.IsRotationSphereLit) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.IsRotationSphereLit = newBoolValue; } // Let the user control the visibility of the rotation guide EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.Toggle("Show Rotation Guide", _rotationGizmo.ShowRotationGuide); if (newBoolValue != _rotationGizmo.ShowRotationGuide) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowRotationGuide = newBoolValue; } // Let the user control the rotation guide line color newColorValue = EditorGUILayout.ColorField("Rotation Guide Line Color", _rotationGizmo.RotationGuieLineColor); if (newColorValue != _rotationGizmo.RotationGuieLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationGuieLineColor = newColorValue; } // Let the user control the color of the rotation guide disc newColorValue = EditorGUILayout.ColorField("Rotation Guide Disc Color", _rotationGizmo.RotationGuideDiscColor); if (newColorValue != _rotationGizmo.RotationGuideDiscColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.RotationGuideDiscColor = newColorValue; } // Let the user control the visibility of the rotation sphere boundary EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.Toggle(_runtimeOnlyPropertyPrefix + "Show Rotation Sphere Boundary", _rotationGizmo.ShowSphereBoundary); if (newBoolValue != _rotationGizmo.ShowSphereBoundary) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowSphereBoundary = newBoolValue; } // Let the user control the rotation sphere boundary line color newColorValue = EditorGUILayout.ColorField(_runtimeOnlyPropertyPrefix + "Rotation Sphere Boundary Line Color", _rotationGizmo.SphereBoundaryLineColor); if (newColorValue != _rotationGizmo.SphereBoundaryLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.SphereBoundaryLineColor = newColorValue; } // Let the user control the visibility of the camera look rotation circle EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.Toggle("Show Camera Look Rotation Circle", _rotationGizmo.ShowCameraLookRotationCircle); if (newBoolValue != _rotationGizmo.ShowCameraLookRotationCircle) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.ShowCameraLookRotationCircle = newBoolValue; } // Let the user control the camera look rotation circle scale newFloatValue = EditorGUILayout.FloatField("Camera Look Rotation Circle Radius Scale", _rotationGizmo.CameraLookRotationCircleRadiusScale); if (newFloatValue != _rotationGizmo.CameraLookRotationCircleRadiusScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleRadiusScale = newFloatValue; } // Let the user control the camera look rotation circle line color newColorValue = EditorGUILayout.ColorField("Camera Look Rotation Circle Line Color", _rotationGizmo.CameraLookRotationCircleLineColor); if (newColorValue != _rotationGizmo.SphereBoundaryLineColor) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleLineColor = newColorValue; } // Let the user control the color of the camera look rotation circle when it is selected newColorValue = EditorGUILayout.ColorField(_runtimeOnlyPropertyPrefix + "Camera Look Rotation Circle Color (Selected)", _rotationGizmo.CameraLookRotationCircleColorWhenSelected); if (newColorValue != _rotationGizmo.CameraLookRotationCircleColorWhenSelected) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.CameraLookRotationCircleColorWhenSelected = newColorValue; } // Let the user specify the snap step value EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField(_runtimeOnlyPropertyPrefix + "Snap Step Value (In Degrees)", _rotationGizmo.SnapSettings.StepValueInDegrees); if (newFloatValue != _rotationGizmo.SnapSettings.StepValueInDegrees) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_rotationGizmo); _rotationGizmo.SnapSettings.StepValueInDegrees = newFloatValue; } // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view SceneView.RepaintAll(); }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { const int indentLevel = 2; if (RuntimeEditorApplication.Instance.UseCustomCamera) { EditorGUILayout.HelpBox("Some camera properties can not be modified when a custom camera is used. You can use the " + "Runtime Editor Application Inspector to change this.", UnityEditor.MessageType.Info); EditorGUILayout.BeginVertical("Box"); RenderCameraBackgroundSettingsCtrls(indentLevel); EditorGUILayout.EndVertical(); return; } float newFloatValue; int oldIndentLevel = EditorGUI.indentLevel; EditorGUILayout.BeginVertical("Box"); // Let the user change the zoom settings EditorGUI.indentLevel = indentLevel - 1; _zoomSettingsAreVisible = EditorGUILayout.Foldout(_zoomSettingsAreVisible, "Zoom Settings"); if (_zoomSettingsAreVisible) { EditorCameraZoomSettings zoomSettings = _editorCamera.ZoomSettings; EditorGUI.indentLevel = indentLevel; // Let the user specify if camera zoom is enabled/disabled bool newBool = EditorGUILayout.ToggleLeft("Is Zoom Enabled", zoomSettings.IsZoomEnabled); if (newBool != zoomSettings.IsZoomEnabled) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.IsZoomEnabled = newBool; } // Let the user specify the camera zoom mode EditorCameraZoomMode newZoomMode = (EditorCameraZoomMode)EditorGUILayout.EnumPopup("Zoom Mode", zoomSettings.ZoomMode); if (newZoomMode != zoomSettings.ZoomMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.ZoomMode = newZoomMode; } if (newZoomMode == EditorCameraZoomMode.Smooth) { // Let the user choose a smooth value for both camera types EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.Slider("Orthographic Smooth Value", zoomSettings.OrthographicSmoothValue, EditorCameraZoomSettings.MinSmoothValue, EditorCameraZoomSettings.MaxSmoothValue); if (newFloatValue != zoomSettings.OrthographicSmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicSmoothValue = newFloatValue; } newFloatValue = EditorGUILayout.Slider("Perspective Smooth Value", zoomSettings.PerspectiveSmoothValue, EditorCameraZoomSettings.MinSmoothValue, EditorCameraZoomSettings.MaxSmoothValue); if (newFloatValue != zoomSettings.PerspectiveSmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveSmoothValue = newFloatValue; } } if (newZoomMode == EditorCameraZoomMode.Standard) { // Let the user specify the zoom speed when the camera operates in ortho mode and the zoom mode is set to 'Standard' EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Orthographic Standard Zoom Speed", zoomSettings.OrthographicStandardZoomSpeed); if (newFloatValue != zoomSettings.OrthographicStandardZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicStandardZoomSpeed = newFloatValue; } // Let the user specify the zoom speed when the camera operates in perspective mode and the zoom mode is set to 'Standard' newFloatValue = EditorGUILayout.FloatField("Perspective Standard Zoom Speed", zoomSettings.PerspectiveStandardZoomSpeed); if (newFloatValue != zoomSettings.PerspectiveStandardZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveStandardZoomSpeed = newFloatValue; } } if (newZoomMode == EditorCameraZoomMode.Smooth) { // Let the user specify the zoom speed when the camera operates in ortho mode and the zoom mode is set to 'Smooth' EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Orthographic Smooth Zoom Speed", zoomSettings.OrthographicSmoothZoomSpeed); if (newFloatValue != zoomSettings.OrthographicSmoothZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicSmoothZoomSpeed = newFloatValue; } // Let the user specify the zoom speed when the camera operates in perspective mode and the zoom mode is set to 'Smooth' newFloatValue = EditorGUILayout.FloatField("Perspective Smooth Zoom Speed", zoomSettings.PerspectiveSmoothZoomSpeed); if (newFloatValue != zoomSettings.PerspectiveSmoothZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveSmoothZoomSpeed = newFloatValue; } } } // Let the user change the pan settings EditorGUI.indentLevel = indentLevel - 1; _panSettingsAreVisible = EditorGUILayout.Foldout(_panSettingsAreVisible, "Pan Settings"); if (_panSettingsAreVisible) { EditorCameraPanSettings panSettings = _editorCamera.PanSettings; EditorGUI.indentLevel = indentLevel; // Let the user choose the pan mode EditorCameraPanMode newPanMode = (EditorCameraPanMode)EditorGUILayout.EnumPopup("Pan Mode", panSettings.PanMode); if (newPanMode != panSettings.PanMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.PanMode = newPanMode; } if (panSettings.PanMode == EditorCameraPanMode.Smooth) { // Let the user choose the pan smooth value EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.Slider("Smooth Value", panSettings.SmoothValue, EditorCameraPanSettings.MinSmoothValue, EditorCameraPanSettings.MaxSmoothValue); if (newFloatValue != panSettings.SmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.SmoothValue = newFloatValue; } // Let the user choose the smooth pan speed newFloatValue = EditorGUILayout.FloatField("Smooth Pan Speed", panSettings.SmoothPanSpeed); if (newFloatValue != panSettings.SmoothPanSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.SmoothPanSpeed = newFloatValue; } } else { // Let the user choose the standard pan speed newFloatValue = EditorGUILayout.FloatField("Standard Pan Speed", panSettings.StandardPanSpeed); if (newFloatValue != panSettings.StandardPanSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.StandardPanSpeed = newFloatValue; } } // Let the user specify which pan axes should be inverted EditorGUILayout.Separator(); bool newBoolean = EditorGUILayout.ToggleLeft("Invert X Axis", panSettings.InvertXAxis); if (newBoolean != panSettings.InvertXAxis) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.InvertXAxis = newBoolean; } newBoolean = EditorGUILayout.ToggleLeft("Invert Y Axis", panSettings.InvertYAxis); if (newBoolean != panSettings.InvertYAxis) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.InvertYAxis = newBoolean; } } // Let the user change the focus settings EditorGUI.indentLevel = indentLevel - 1; _focusSettingsAreVisible = EditorGUILayout.Foldout(_focusSettingsAreVisible, "Focus Settings"); if (_focusSettingsAreVisible) { EditorCameraFocusSettings focusSettings = _editorCamera.FocusSettings; EditorGUI.indentLevel = indentLevel; // Let the user choose the focus mode EditorCameraFocusMode newFocusMode = (EditorCameraFocusMode)EditorGUILayout.EnumPopup("Focus Mode", focusSettings.FocusMode); if (newFocusMode != focusSettings.FocusMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.FocusMode = newFocusMode; } // Continue drawing the GUI based on the active focus mode if (focusSettings.FocusMode == EditorCameraFocusMode.ConstantSpeed) { // Let the user specify the constant focus speed EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Constant Focus Speed", focusSettings.ConstantFocusSpeed); if (newFloatValue != focusSettings.ConstantFocusSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.ConstantFocusSpeed = newFloatValue; } } else if (focusSettings.FocusMode == EditorCameraFocusMode.Smooth) { // Let the user specify the smooth focus time EditorGUILayout.Separator(); EditorGUILayout.LabelField("Note: Time value is approximate.", EditorGUIStyles.GetInformativeLabelStyle()); newFloatValue = EditorGUILayout.FloatField("Smooth Focus Time", focusSettings.SmoothFocusTime); if (newFloatValue != focusSettings.SmoothFocusTime) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.SmoothFocusTime = newFloatValue; } } // We always let the user choose the focus distance scale newFloatValue = EditorGUILayout.FloatField("Focus Distance Scale", focusSettings.FocusDistanceScale); if (newFloatValue != focusSettings.FocusDistanceScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.FocusDistanceScale = newFloatValue; } } // Let the user specify the camera rotation speed in degree units EditorGUI.indentLevel = oldIndentLevel; newFloatValue = EditorGUILayout.FloatField("Rotation Speed (Degrees)", _editorCamera.RotationSpeedInDegrees); if (newFloatValue != _editorCamera.RotationSpeedInDegrees) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); _editorCamera.RotationSpeedInDegrees = newFloatValue; } // Let the user specify the camera move spedd in units/second newFloatValue = EditorGUILayout.FloatField("Move Speed (units/second)", _editorCamera.MoveSettings.MoveSpeed); if (newFloatValue != _editorCamera.MoveSettings.MoveSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); _editorCamera.MoveSettings.MoveSpeed = newFloatValue; } RenderCameraBackgroundSettingsCtrls(indentLevel); EditorGUILayout.EndVertical(); _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _editorCamera.MoveForwardShortcut.RenderView(_editorCamera); _editorCamera.MoveBackShortcut.RenderView(_editorCamera); _editorCamera.StrafeLeftShortcut.RenderView(_editorCamera); _editorCamera.StrafeRightShortcut.RenderView(_editorCamera); _editorCamera.MoveUpShortcut.RenderView(_editorCamera); _editorCamera.MoveDownShortcut.RenderView(_editorCamera); _editorCamera.FocusOnSelectionShortcut.RenderView(_editorCamera); _editorCamera.CameraLookAroundShortcut.RenderView(_editorCamera); _editorCamera.CameraOrbitShortcut.RenderView(_editorCamera); _editorCamera.CameraPanShortcut.RenderView(_editorCamera); } }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { float newFloatValue; const int indentLevel = 1; bool newBool = EditorGUILayout.ToggleLeft("Take Zoom Factor Into Account", _editorCamera.TakeZoomFactorIntoAccount); if (newBool != _editorCamera.TakeZoomFactorIntoAccount) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); _editorCamera.TakeZoomFactorIntoAccount = newBool; } // Let the user change the zoom settings _zoomSettingsAreVisible = EditorGUILayout.Foldout(_zoomSettingsAreVisible, "Zoom Settings"); if (_zoomSettingsAreVisible) { EditorCameraZoomSettings zoomSettings = _editorCamera.ZoomSettings; EditorGUI.indentLevel += indentLevel; // Let the user specify if camera zoom is enabled/disabled newBool = EditorGUILayout.ToggleLeft("Is Zoom Enabled", zoomSettings.IsZoomEnabled); if (newBool != zoomSettings.IsZoomEnabled) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.IsZoomEnabled = newBool; } // Let the user specify the camera zoom mode EditorCameraZoomMode newZoomMode = (EditorCameraZoomMode)EditorGUILayout.EnumPopup("Zoom Mode", zoomSettings.ZoomMode); if (newZoomMode != zoomSettings.ZoomMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.ZoomMode = newZoomMode; } if (newZoomMode == EditorCameraZoomMode.Smooth) { // Let the user choose a smooth value for both camera types EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.Slider("Orthographic Smooth Value", zoomSettings.OrthographicSmoothValue, EditorCameraZoomSettings.MinSmoothValue, EditorCameraZoomSettings.MaxSmoothValue); if (newFloatValue != zoomSettings.OrthographicSmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicSmoothValue = newFloatValue; } newFloatValue = EditorGUILayout.Slider("Perspective Smooth Value", zoomSettings.PerspectiveSmoothValue, EditorCameraZoomSettings.MinSmoothValue, EditorCameraZoomSettings.MaxSmoothValue); if (newFloatValue != zoomSettings.PerspectiveSmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveSmoothValue = newFloatValue; } } if (newZoomMode == EditorCameraZoomMode.Standard) { // Let the user specify the zoom speed when the camera operates in ortho mode and the zoom mode is set to 'Standard' EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Orthographic Standard Zoom Speed", zoomSettings.OrthographicStandardZoomSpeed); if (newFloatValue != zoomSettings.OrthographicStandardZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicStandardZoomSpeed = newFloatValue; } // Let the user specify the zoom speed when the camera operates in perspective mode and the zoom mode is set to 'Standard' newFloatValue = EditorGUILayout.FloatField("Perspective Standard Zoom Speed", zoomSettings.PerspectiveStandardZoomSpeed); if (newFloatValue != zoomSettings.PerspectiveStandardZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveStandardZoomSpeed = newFloatValue; } } if (newZoomMode == EditorCameraZoomMode.Smooth) { // Let the user specify the zoom speed when the camera operates in ortho mode and the zoom mode is set to 'Smooth' EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Orthographic Smooth Zoom Speed", zoomSettings.OrthographicSmoothZoomSpeed); if (newFloatValue != zoomSettings.OrthographicSmoothZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.OrthographicSmoothZoomSpeed = newFloatValue; } // Let the user specify the zoom speed when the camera operates in perspective mode and the zoom mode is set to 'Smooth' newFloatValue = EditorGUILayout.FloatField("Perspective Smooth Zoom Speed", zoomSettings.PerspectiveSmoothZoomSpeed); if (newFloatValue != zoomSettings.PerspectiveSmoothZoomSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); zoomSettings.PerspectiveSmoothZoomSpeed = newFloatValue; } } EditorGUI.indentLevel -= indentLevel; } // Let the user change the pan settings _panSettingsAreVisible = EditorGUILayout.Foldout(_panSettingsAreVisible, "Pan Settings"); if (_panSettingsAreVisible) { EditorCameraPanSettings panSettings = _editorCamera.PanSettings; EditorGUI.indentLevel += indentLevel; // Let the user choose the pan mode EditorCameraPanMode newPanMode = (EditorCameraPanMode)EditorGUILayout.EnumPopup("Pan Mode", panSettings.PanMode); if (newPanMode != panSettings.PanMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.PanMode = newPanMode; } if (panSettings.PanMode == EditorCameraPanMode.Smooth) { // Let the user choose the pan smooth value EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.Slider("Smooth Value", panSettings.SmoothValue, EditorCameraPanSettings.MinSmoothValue, EditorCameraPanSettings.MaxSmoothValue); if (newFloatValue != panSettings.SmoothValue) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.SmoothValue = newFloatValue; } // Let the user choose the smooth pan speed newFloatValue = EditorGUILayout.FloatField("Smooth Pan Speed", panSettings.SmoothPanSpeed); if (newFloatValue != panSettings.SmoothPanSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.SmoothPanSpeed = newFloatValue; } } else { // Let the user choose the standard pan speed newFloatValue = EditorGUILayout.FloatField("Standard Pan Speed", panSettings.StandardPanSpeed); if (newFloatValue != panSettings.StandardPanSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.StandardPanSpeed = newFloatValue; } } // Let the user specify which pan axes should be inverted EditorGUILayout.Separator(); bool newBoolean = EditorGUILayout.ToggleLeft("Invert X Axis", panSettings.InvertXAxis); if (newBoolean != panSettings.InvertXAxis) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.InvertXAxis = newBoolean; } newBoolean = EditorGUILayout.ToggleLeft("Invert Y Axis", panSettings.InvertYAxis); if (newBoolean != panSettings.InvertYAxis) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); panSettings.InvertYAxis = newBoolean; } EditorGUI.indentLevel -= indentLevel; } // Let the user change the focus settings _focusSettingsAreVisible = EditorGUILayout.Foldout(_focusSettingsAreVisible, "Focus Settings"); if (_focusSettingsAreVisible) { EditorCameraFocusSettings focusSettings = _editorCamera.FocusSettings; EditorGUI.indentLevel += indentLevel; // Let the user choose the focus mode EditorCameraFocusMode newFocusMode = (EditorCameraFocusMode)EditorGUILayout.EnumPopup("Focus Mode", focusSettings.FocusMode); if (newFocusMode != focusSettings.FocusMode) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.FocusMode = newFocusMode; } // Continue drawing the GUI based on the active focus mode if (focusSettings.FocusMode == EditorCameraFocusMode.ConstantSpeed) { // Let the user specify the constant focus speed EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Constant Focus Speed", focusSettings.ConstantFocusSpeed); if (newFloatValue != focusSettings.ConstantFocusSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.ConstantFocusSpeed = newFloatValue; } } else if (focusSettings.FocusMode == EditorCameraFocusMode.Smooth) { // Let the user specify the smooth focus time EditorGUILayout.Separator(); EditorGUILayout.LabelField("Note: Time value is approximate.", EditorGUIStyles.GetInformativeLabelStyle()); newFloatValue = EditorGUILayout.FloatField("Smooth Focus Time", focusSettings.SmoothFocusTime); if (newFloatValue != focusSettings.SmoothFocusTime) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.SmoothFocusTime = newFloatValue; } } // We always let the user choose the focus distance scale newFloatValue = EditorGUILayout.FloatField("Focus Distance Scale", focusSettings.FocusDistanceScale); if (newFloatValue != focusSettings.FocusDistanceScale) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); focusSettings.FocusDistanceScale = newFloatValue; } EditorGUI.indentLevel -= indentLevel; } // Let the user specify the camera rotation speed in degree units EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Rotation Speed (Degrees)", _editorCamera.RotationSpeedInDegrees); if (newFloatValue != _editorCamera.RotationSpeedInDegrees) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); _editorCamera.RotationSpeedInDegrees = newFloatValue; } // Let the user specify the camera move spedd in units/second newFloatValue = EditorGUILayout.FloatField("Move Speed (units/second)", _editorCamera.MoveSettings.MoveSpeed); if (newFloatValue != _editorCamera.MoveSettings.MoveSpeed) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_editorCamera); _editorCamera.MoveSettings.MoveSpeed = newFloatValue; } _bkSettingsAreVisible = EditorGUILayout.Foldout(_bkSettingsAreVisible, "Background Settings"); if (_bkSettingsAreVisible) { EditorGUI.indentLevel += 1; _editorCamera.Background.RenderView(_editorCamera); EditorGUI.indentLevel -= 1; } }
/// <summary> /// Renders the shortcut view inside the Inspector. /// </summary> /// <param name="parentMono"> /// The parent Mono object which holds a reference to the shortcut. /// </param> public void RenderView(MonoBehaviour parentMono) { const int indentAmount = 1; // Shortcut name GUIStyle style = new GUIStyle("label"); style.fontStyle = FontStyle.Bold; EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("[" + Name + "]", style); // Number of keys int newNumKeys = EditorGUILayout.IntField("Num keys", NumberOfKeys); if (newNumKeys != NumberOfKeys) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); NumberOfKeys = newNumKeys; } // For each possible key, let the user specify its key code for (int keyIndex = 0; keyIndex < _numberOfKeys; ++keyIndex) { int selectedIndex = _availableKeyNames.IndexOf(_keys[keyIndex].ToString()); int newIndex = EditorGUILayout.Popup("Key" + keyIndex.ToString(), selectedIndex, _availableKeyNames.ToArray()); if (newIndex != selectedIndex) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _keys[keyIndex] = _availableKeys[newIndex]; } } // Modifiers bool newBool = EditorGUILayout.ToggleLeft("<Modifiers>", _useModifiers); if (_useModifiers != newBool) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _useModifiers = newBool; } if (_useModifiers) { EditorGUI.indentLevel += indentAmount; EditorGUILayout.BeginVertical(); newBool = EditorGUILayout.ToggleLeft(KeyCode.LeftControl.ToString(), _lCtrl); if (newBool != _lCtrl) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lCtrl = newBool; } newBool = EditorGUILayout.ToggleLeft(KeyCode.LeftCommand.ToString(), _lCmd); if (newBool != _lCmd) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lCmd = newBool; } newBool = EditorGUILayout.ToggleLeft(KeyCode.LeftAlt.ToString(), _lAlt); if (newBool != _lAlt) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lAlt = newBool; } newBool = EditorGUILayout.ToggleLeft(KeyCode.LeftShift.ToString(), _lShift); if (newBool != _lShift) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lShift = newBool; } EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= indentAmount; } // Mouse buttons newBool = EditorGUILayout.ToggleLeft("<Mouse buttons>", _useMouseButtons); if (_useMouseButtons != newBool) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _useMouseButtons = newBool; } if (_useMouseButtons) { EditorGUI.indentLevel += indentAmount; EditorGUILayout.BeginVertical(); newBool = EditorGUILayout.ToggleLeft(MouseButton.Left.ToString(), _lMouseBtn); if (newBool != _lMouseBtn) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _lMouseBtn = newBool; } newBool = EditorGUILayout.ToggleLeft(MouseButton.Right.ToString(), _rMouseBtn); if (newBool != _rMouseBtn) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _rMouseBtn = newBool; } newBool = EditorGUILayout.ToggleLeft(MouseButton.Middle.ToString(), _mMouseBtn); if (newBool != _mMouseBtn) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(parentMono); _mMouseBtn = newBool; } EditorGUILayout.EndVertical(); EditorGUI.indentLevel -= indentAmount; } EditorGUILayout.EndVertical(); }
/// <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); } }
/// <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(); }
/// <summary> /// Called when the inspector needs to be rendered. /// </summary> public override void OnInspectorGUI() { // Draw the common gizmo properties base.OnInspectorGUI(); EditorGUILayout.BeginVertical("Box"); // Let the user control the gizmo axis length EditorGUILayout.Separator(); float newFloatValue = EditorGUILayout.FloatField("Axis Length", _scaleGizmo.AxisLength); if (newFloatValue != _scaleGizmo.AxisLength) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AxisLength = newFloatValue; } // Let the user control the scale box width newFloatValue = EditorGUILayout.FloatField("Scale Box Width", _scaleGizmo.ScaleBoxWidth); if (newFloatValue != _scaleGizmo.ScaleBoxWidth) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ScaleBoxWidth = newFloatValue; } // Let the user control the scale box height newFloatValue = EditorGUILayout.FloatField("Scale Box Height", _scaleGizmo.ScaleBoxHeight); if (newFloatValue != _scaleGizmo.ScaleBoxHeight) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ScaleBoxHeight = newFloatValue; } // Let the user control the scale box depth newFloatValue = EditorGUILayout.FloatField("Scale Box Depth", _scaleGizmo.ScaleBoxDepth); if (newFloatValue != _scaleGizmo.ScaleBoxDepth) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ScaleBoxDepth = newFloatValue; } // Let the user specify whether or not the scale boxes must be lit bool newBoolValue = EditorGUILayout.ToggleLeft("Are Scale Boxes Lit", _scaleGizmo.AreScaleBoxesLit); if (newBoolValue != _scaleGizmo.AreScaleBoxesLit) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AreScaleBoxesLit = newBoolValue; } // Let the user specify whether or not the length of the scale axes must be adjusted while performing a scale operation newBoolValue = EditorGUILayout.ToggleLeft("Adjust Axis Length While Scaling Objects", _scaleGizmo.AdjustAxisLengthWhileScalingObjects); if (newBoolValue != _scaleGizmo.AdjustAxisLengthWhileScalingObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AdjustAxisLengthWhileScalingObjects = newBoolValue; } // Let the user change the length of the adjacent sides of the multi-axis triangles EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Multi Axis Triangle Side Length", _scaleGizmo.MultiAxisTriangleSideLength); if (newFloatValue != _scaleGizmo.MultiAxisTriangleSideLength) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.MultiAxisTriangleSideLength = newFloatValue; } // Let the user specify whether or not the mulit-axis triangles must be adjusted during runtime for better visibility newBoolValue = EditorGUILayout.ToggleLeft("Adjust Multi Axis For Better Visibility", _scaleGizmo.AdjustMultiAxisForBetterVisibility); if (newBoolValue != _scaleGizmo.AdjustMultiAxisForBetterVisibility) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AdjustMultiAxisForBetterVisibility = newBoolValue; } // Let the user specify whether or not the multi-axis triangles must have their area adjusted during a scale operation newBoolValue = EditorGUILayout.ToggleLeft("Adjust Multi Axis Triangles While Scaling Objects", _scaleGizmo.AdjustMultiAxisTrianglesWhileScalingObjects); if (newBoolValue != _scaleGizmo.AdjustMultiAxisTrianglesWhileScalingObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AdjustMultiAxisTrianglesWhileScalingObjects = newBoolValue; } // Let the user specify the color of the square which can be used to scale along all axes at once EditorGUILayout.Separator(); Color newColorValue = EditorGUILayout.ColorField("Color Of All-Axes Square Lines", _scaleGizmo.ColorOfAllAxesSquareLines); if (newColorValue != _scaleGizmo.ColorOfAllAxesSquareLines) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ColorOfAllAxesSquareLines = newColorValue; } // Let the user specify the color of the square which can be used to scale along all axes at once when it is selected newColorValue = EditorGUILayout.ColorField("Color Of All-Axes Square Lines (Selected)", _scaleGizmo.ColorOfAllAxesSquareLinesWhenSelected); if (newColorValue != _scaleGizmo.ColorOfAllAxesSquareLinesWhenSelected) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ColorOfAllAxesSquareLinesWhenSelected = newColorValue; } // Let the user specify the screen size of the square which can be used to scale along all axes at once newFloatValue = EditorGUILayout.FloatField("Screen Size Of All-Axes Square", _scaleGizmo.ScreenSizeOfAllAxesSquare); if (newFloatValue != _scaleGizmo.ScreenSizeOfAllAxesSquare) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ScreenSizeOfAllAxesSquare = newFloatValue; } // Let the user specify whether or not the all-axes scale square must have its size adjusted during a scale operation newBoolValue = EditorGUILayout.ToggleLeft("Adjust All-Axes Square While Scaling Objects", _scaleGizmo.AdjustAllAxesScaleSquareWhileScalingObjects); if (newBoolValue != _scaleGizmo.AdjustAllAxesScaleSquareWhileScalingObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AdjustAllAxesScaleSquareWhileScalingObjects = newBoolValue; } // Let the user specify whether or not the objects local axes must be drawn during a scale operation EditorGUILayout.Separator(); newBoolValue = EditorGUILayout.ToggleLeft("Draw Objects Local Axes While Scaling", _scaleGizmo.DrawObjectsLocalAxesWhileScaling); if (newBoolValue != _scaleGizmo.DrawObjectsLocalAxesWhileScaling) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.DrawObjectsLocalAxesWhileScaling = newBoolValue; } // If the objects local coordinate system axes must be drawn, we have some more controls to draw if (_scaleGizmo.DrawObjectsLocalAxesWhileScaling) { // Let the user choose the objects' local axis length newFloatValue = EditorGUILayout.FloatField("Objects Local Axes Length", _scaleGizmo.ObjectsLocalAxesLength); if (newFloatValue != _scaleGizmo.ObjectsLocalAxesLength) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.ObjectsLocalAxesLength = newFloatValue; } // Let the user specify whether or not the objects' local axes must have their size preserved in screen space newBoolValue = EditorGUILayout.ToggleLeft("Preserve Axes Screen Size", _scaleGizmo.PreserveObjectLocalAxesScreenSize); if (newBoolValue != _scaleGizmo.PreserveObjectLocalAxesScreenSize) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.PreserveObjectLocalAxesScreenSize = newBoolValue; } // Let the user specify whether or not the objects' local axes must be scaled along with the objects newBoolValue = EditorGUILayout.ToggleLeft("Adjust Object Local Axes While Scaling", _scaleGizmo.AdjustObjectLocalAxesWhileScalingObjects); if (newBoolValue != _scaleGizmo.AdjustObjectLocalAxesWhileScalingObjects) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.AdjustObjectLocalAxesWhileScalingObjects = newBoolValue; } } // Let the user specify the snap step value EditorGUILayout.Separator(); newFloatValue = EditorGUILayout.FloatField("Snap Step Value (In World Units)", _scaleGizmo.SnapSettings.StepValueInWorldUnits); if (newFloatValue != _scaleGizmo.SnapSettings.StepValueInWorldUnits) { UnityEditorUndoHelper.RecordObjectForInspectorPropertyChange(_scaleGizmo); _scaleGizmo.SnapSettings.StepValueInWorldUnits = newFloatValue; } EditorGUILayout.EndVertical(); RenderLayerMaskControls(); _keyMappingsAreVisible = EditorGUILayout.Foldout(_keyMappingsAreVisible, "Key mappings"); if (_keyMappingsAreVisible) { _scaleGizmo.EnableStepSnappingShortcut.RenderView(_scaleGizmo); _scaleGizmo.EnableScaleAlongAllAxesShortcut.RenderView(_scaleGizmo); } // Make sure that if any color properites have been modified, the changes can be seen immediately in the scene view SceneView.RepaintAll(); }