public override void OnInspectorGUI() { m_setter.Clear(); serializedObject.DrawScript(); GUI.enabled = false; EditorGUILayout.PropertyField(m_serializedProperties.ComputeShader, Labels.ComputeShader); GUI.enabled = true; GUI.enabled = false; EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup); GUI.enabled = true; bool isControlledExternally = m_serializedProperties.SettingsControlledByGrid.boolValue; if (isControlledExternally) { EditorGUILayout.HelpBox(Labels.SettingsControlledByGridWarning, MessageType.Info); return; } GUI.enabled = !isControlledExternally; m_setter.DrawProperty(Labels.AutoUpdate, m_serializedProperties.AutoUpdate); m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_sdfGroupMeshGen.OnOutputModeChanged); OutputMode outputMode = (OutputMode)m_serializedProperties.OutputMode.enumValueIndex; if (outputMode == OutputMode.Procedural) { m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial); } else if (outputMode == OutputMode.MeshFilter) { m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous); } if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode); CellSizeMode cellSizeMode = (CellSizeMode)m_serializedProperties.CellSizeMode.enumValueIndex; if (cellSizeMode == CellSizeMode.Fixed) { m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_sdfGroupMeshGen.OnCellSizeChanged); m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_sdfGroupMeshGen.OnCellCountChanged); } else if (cellSizeMode == CellSizeMode.Density) { m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged); m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged); } } } } if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_sdfGroupMeshGen.OnIsosurfaceExtractionTypeChanged); EditorGUILayout.Space(); EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel); m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_sdfGroupMeshGen.OnMaxAngleToleranceChanged); m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_sdfGroupMeshGen.OnVisualNormalSmoothingChanged); EditorGUILayout.Space(); EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel); m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged); if ((EdgeIntersectionType)m_serializedProperties.EdgeIntersectionType.enumValueIndex == EdgeIntersectionType.BinarySearch) { m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel); m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged); if (m_serializedProperties.ApplyGradientDescent.boolValue) { m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged); } } } } if (m_isDebugSettingsOpen = EditorGUILayout.Foldout(m_isDebugSettingsOpen, Labels.DebugSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.ShowGrid, m_serializedProperties.ShowGrid); } } } m_setter.Update(); GUI.enabled = true; }
public override void OnInspectorGUI() { m_setter.Clear(); serializedObject.DrawScript(); if (GUILayout.Button("Update Mesh")) { m_sdfGroupMeshGen.UpdateMesh(); } GUI.enabled = false; EditorGUILayout.PropertyField(m_serializedProperties.ComputeShader, Labels.ComputeShader); GUI.enabled = true; GUI.enabled = false; EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup); GUI.enabled = true; m_setter.DrawProperty(Labels.AutoUpdate, m_serializedProperties.AutoUpdate); m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_sdfGroupMeshGen.OnOutputModeChanged); if (m_sdfGroupMeshGen.OutputMode == OutputMode.Procedural) { m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial); } else if (m_sdfGroupMeshGen.OutputMode == OutputMode.MeshFilter) { m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous); } if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode); if (m_sdfGroupMeshGen.CellSizeMode == CellSizeMode.Fixed) { m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_sdfGroupMeshGen.OnCellSizeChanged); m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_sdfGroupMeshGen.OnCellCountChanged); } else if (m_sdfGroupMeshGen.CellSizeMode == CellSizeMode.Density) { m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged); m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged); } } } } if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_sdfGroupMeshGen.OnIsosurfaceExtractionTypeChanged); if (m_sdfGroupMeshGen.IsosurfaceExtractionType == IsosurfaceExtractionType.DualContouring) { m_setter.DrawFloatSetting(Labels.ConstrainToCellUnits, m_serializedProperties.ConstrainToCellUnits, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnConstrainToCellUnitsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel); m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_sdfGroupMeshGen.OnMaxAngleToleranceChanged); m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_sdfGroupMeshGen.OnVisualNormalSmoothingChanged); if (m_sdfGroupMeshGen.IsosurfaceExtractionType == IsosurfaceExtractionType.DualContouring) { EditorGUILayout.Space(); EditorGUILayout.LabelField("QEF Settings", EditorStyles.boldLabel); m_setter.DrawBoolSetting(Labels.OverrideQEFSettings, m_serializedProperties.OverrideQEFSettings, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged); if (m_sdfGroupMeshGen.OverrideQEFSettings) { m_setter.DrawIntSetting(Labels.QEFSweeps, m_serializedProperties.QEFSweeps, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged); m_setter.DrawFloatSetting(Labels.QEFPseudoInverseThreshold, m_serializedProperties.QEFPseudoInverseThreshold, min: 1e-7f, onValueChangedCallback: m_sdfGroupMeshGen.OnQEFSettingsOverrideChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Nudge Settings", EditorStyles.boldLabel); m_setter.DrawFloatSetting(Labels.NudgeVerticesToAverageNormalScalar, m_serializedProperties.NudgeVerticesToAverageNormalScalar, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnNudgeSettingsChanged); m_setter.DrawFloatSetting(Labels.NudgeMaxMagnitude, m_serializedProperties.NudgeMaxMagnitude, min: 0f, onValueChangedCallback: m_sdfGroupMeshGen.OnNudgeSettingsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel); m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_sdfGroupMeshGen.OnEdgeIntersectionTypeChanged); if (m_sdfGroupMeshGen.EdgeIntersectionType == EdgeIntersectionType.BinarySearch) { m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel); m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_sdfGroupMeshGen.OnApplyGradientDescentChanged); if (m_sdfGroupMeshGen.ApplyGradientDescent) { m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged); } } } } if (m_isDebugSettingsOpen = EditorGUILayout.Foldout(m_isDebugSettingsOpen, Labels.DebugSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.ShowGrid, m_serializedProperties.ShowGrid); } } } m_setter.Update(); }