public override void OnInspectorGUI() { m_setter.Clear(); serializedObject.DrawScript(); GUI.enabled = false; EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup); EditorGUILayout.PropertyField(m_serializedProperties.Material, Labels.Material); GUI.enabled = true; if (m_isVisualSettingsOpen = EditorGUILayout.Foldout(m_isVisualSettingsOpen, Labels.VisualSettings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawVector3Setting(Labels.Size, m_serializedProperties.Size, onValueChangedCallback: m_raymarcher.UpdateCubeMesh); m_setter.DrawColourSetting(Labels.DiffuseColour, m_serializedProperties.DiffuseColour, m_raymarcher.OnVisualsChanged); m_setter.DrawColourSetting(Labels.AmbientColour, m_serializedProperties.AmbientColour, m_raymarcher.OnVisualsChanged); m_setter.DrawFloatSetting(Labels.GlossPower, m_serializedProperties.GlossPower, onValueChangedCallback: m_raymarcher.OnVisualsChanged); m_setter.DrawFloatSetting(Labels.GlossMultiplier, m_serializedProperties.GlossMultiplier, onValueChangedCallback: m_raymarcher.OnVisualsChanged); } } } m_setter.Update(); }
/// <summary> /// Enables the user to activate this processing method and define its parameters. /// </summary> /// <param name="isCompatible"></param> True if the method is compatible with the source data, false otherwise. public void SectionProcessingMethod(bool isCompatible) { bool isSelected = SectionShouldExecute(isCompatible); if (isSelected && HasAdditionalParameters()) { using (var horizontalScope = new EditorGUILayout.HorizontalScope()) { GeneralToolkit.addedSpace = 20f * EditorGUI.indentLevel; GUILayout.Space(GeneralToolkit.addedSpace); using (var verticalScope = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { SectionAdditionalParameters(); } GeneralToolkit.addedSpace = 0f; } } if (_nestedMethodsToDisplay != null && _nestedMethodsToDisplay.Length > 0) { using (var indentScope = new EditorGUI.IndentLevelScope()) { for (int iter = 0; iter < _nestedMethodsToDisplay.Length; iter++) { bool isNestedMethodCompatible = shouldExecute && _nestedMethodsToDisplay[iter].IsNestedGUIEnabled(); bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && isNestedMethodCompatible; _nestedMethodsToDisplay[iter].SectionProcessingMethod(isNestedMethodCompatible); GUI.enabled = isGUIEnabled; } } } }
public override void OnInspectorGUI() { serializedObject.DrawScript(); EditorGUILayout.PropertyField(m_serializedProperties.IsRunning, Labels.IsRunning); if (m_isSettingsOpen = EditorGUILayout.Foldout(m_isSettingsOpen, Labels.Settings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { if (this.DrawFloatField(Labels.Smoothing, m_serializedProperties.Smoothing, out float val, min: SDFGroup.MIN_SMOOTHING)) { m_sdfGroup.SetSmoothing(val); } if (this.DrawFloatField(Labels.NormalSmoothing, m_serializedProperties.NormalSmoothing, out val, min: SDFGroup.MIN_SMOOTHING)) { m_sdfGroup.SetNormalSmoothing(val); } } } } serializedObject.ApplyModifiedProperties(); }
void DrawHeader() { EditorGUILayout.BeginVertical(bg); IconSetWindow.Instance.Prefs.DrawRulers.value = DrawToggle("Draw guide rulers", IconSetWindow.Instance.Prefs.DrawRulers.value); ShowExtraFields.target = EditorGUILayout.Foldout(ShowExtraFields.target, new GUIContent("Colors"), true); if (EditorGUILayout.BeginFadeGroup(ShowExtraFields.faded)) { using (EditorGUI.IndentLevelScope m = new EditorGUI.IndentLevelScope()) { IconSetWindow.Instance.Prefs.GridBGTint = DrawColorField("BG gradient top", (Color)IconSetWindow.Instance.Prefs.GridBGTint, () => { IconSetWindow.Instance.Prefs.GridBGTint = null; return((Color)IconSetWindow.Instance.Prefs.GridBGTint); }); IconSetWindow.Instance.Prefs.GridGradientTint = DrawColorField("BG gradient bottom", (Color)IconSetWindow.Instance.Prefs.GridGradientTint, () => { IconSetWindow.Instance.Prefs.GridGradientTint = null; return((Color)IconSetWindow.Instance.Prefs.GridGradientTint); }); IconSetWindow.Instance.Prefs.GridForeground = DrawColorField("Grid color 1", (Color)IconSetWindow.Instance.Prefs.GridForeground, () => { IconSetWindow.Instance.Prefs.GridForeground = null; return((Color)IconSetWindow.Instance.Prefs.GridForeground); }); IconSetWindow.Instance.Prefs.GridBackground = DrawColorField("Grid color 2", (Color)IconSetWindow.Instance.Prefs.GridBackground, () => { IconSetWindow.Instance.Prefs.GridBackground = null; return((Color)IconSetWindow.Instance.Prefs.GridBackground); }); IconSetWindow.Instance.Prefs.GridMajorLineColor = DrawColorField("Major line color", (Color)IconSetWindow.Instance.Prefs.GridMajorLineColor, () => { IconSetWindow.Instance.Prefs.GridMajorLineColor = null; return((Color)IconSetWindow.Instance.Prefs.GridMajorLineColor); }); IconSetWindow.Instance.Prefs.GridMinorLineColor = DrawColorField("Minor line color", (Color)IconSetWindow.Instance.Prefs.GridMinorLineColor, () => { IconSetWindow.Instance.Prefs.GridMinorLineColor = null; return((Color)IconSetWindow.Instance.Prefs.GridMinorLineColor); }); } } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); }
/// <inheritdoc/> public override void SectionAdditionalParameters() { // Enable the user to choose the parameters for per-view meshing. if (shouldExecute) { using (var indentScope = new EditorGUI.IndentLevelScope()) PMPerViewMeshesQSTR.SectionAdditionalParameters(); } }
protected virtual void DrawImpl(Rect position, GUIContent label) { var rowHeight = GUI.skin.font.lineHeight; rowHeight += GUI.skin.label.margin.vertical + GUI.skin.label.padding.vertical; var pos = new GUILayoutPosition(position, rowHeight); if (Target.CurrentType == SerializedTarget.Type.SerializedProperty) { using (var scope = new EditorGUI.ChangeCheckScope()) { var foldoutPos = pos.GetSplitPos(3f, 0); _foldout = EditorGUI.Foldout(foldoutPos, _foldout, label); var objFieldPos = pos.GetSplitPos(3f, 1, 2); var newObj = EditorGUI.ObjectField(objFieldPos, Target.ObjectReference, typeof(TDictionary), false); if (scope.changed) { Target.ObjectReference = newObj; } } if (!_foldout || Target.ObjectReference == null) { return; } } else { EditorGUI.LabelField(pos.Pos, label); } var assetInstance = Dictionary; if (assetInstance == null) { pos.IncrementRow(); var labelPos = pos.Pos; EditorGUI.LabelField(labelPos, "Don't Found Reference..."); return; } var SO = new SerializedObject(assetInstance); var(doApply, nextPos) = OnDrawElementsBefore(pos, SO, rowHeight); pos = nextPos; if (doApply) { return; } using (var indent1 = new EditorGUI.IndentLevelScope()) { var indentPos = pos.Indent(true); DrawElements(indentPos, SO, rowHeight); } }
public static Texture2D InlineTexture2DField(string label, Texture2D value, int indentScope = 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(label); using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(indentScope)) { value = EditorGUILayout.ObjectField(value, typeof(Texture2D), false) as Texture2D; } EditorGUILayout.EndHorizontal(); return(value); }
public static Cubemap InlineCubemapField(string label, Cubemap value, int indentScope = 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(label); using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(indentScope)) { value = EditorGUILayout.ObjectField(value, typeof(Cubemap), false) as Cubemap; } EditorGUILayout.EndHorizontal(); return(value); }
public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) { // Grab every field SerializedProperty key = property.FindPropertyRelative("key"); SerializedProperty dictionary = property.FindPropertyRelative("dictionary"); using (EditorGUI.PropertyScope scope = new EditorGUI.PropertyScope(rect, label, property)) { // Calculate height float previewHeight = rect.height; rect.height = EditorGUIUtility.singleLineHeight; previewHeight -= rect.height; Width = rect.width; // Draw label of object property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, scope.content); if (property.isExpanded == true) { // Indent using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { // Draw the properties regularly rect = DrawFields(rect, key, dictionary); } } } if (property.isExpanded == true) { // Indent using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { // Update status TranslationDictionary translationDictionary = dictionary.objectReferenceValue as TranslationDictionary; string translationKey = key.stringValue; Status status = UpdateMessageStatus(translationDictionary, translationKey); // Draw preview rect = DrawPreviewLabel(rect, status); // Draw HelpBox rect = DrawHelpBox(rect); // Draw preview rect = DrawTextPreview(rect, status, translationKey, translationDictionary); // Show button to add a new translation key rect = DrawButton(rect, status, translationDictionary, translationKey, dictionary); } } }
public override void OnInspectorGUI() { serializedObject.DrawScript(); m_setter.Clear(); m_setter.DrawProperty(Labels.MeshAsset, m_serializedProperties.MeshAsset); bool hasMeshAsset = m_serializedProperties.MeshAsset.objectReferenceValue; if (!hasMeshAsset) { EditorGUILayout.HelpBox(Labels.MeshAssetRequiredMessage, MessageType.Warning); } GUI.enabled = hasMeshAsset; m_setter.DrawProperty(Labels.Operation, m_serializedProperties.Operation); m_setter.DrawProperty(Labels.Flip, m_serializedProperties.Flip); m_setter.DrawFloatSetting(Labels.Smoothing, m_serializedProperties.Smoothing, min: 0f); if (m_isMaterialOpen = EditorGUILayout.Foldout(m_isMaterialOpen, Labels.Material, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.MaterialType, m_serializedProperties.MaterialType); if (m_sdfMesh.Material.Type != SDFMaterial.MaterialType.None) { if (m_sdfMesh.Material.Type == SDFMaterial.MaterialType.Texture) { m_setter.DrawProperty(Labels.MaterialTexture, m_serializedProperties.MaterialTexture); } m_setter.DrawProperty(Labels.Colour, m_serializedProperties.Colour); m_setter.DrawFloatSetting(Labels.MaterialSmoothing, m_serializedProperties.MaterialSmoothing, min: 0f); m_setter.DrawProperty(Labels.Emission, m_serializedProperties.Emission); m_setter.DrawProperty(Labels.Metallic, m_serializedProperties.Metallic); m_setter.DrawProperty(Labels.Smoothness, m_serializedProperties.Smoothness); m_setter.DrawProperty(Labels.SubsurfaceColour, m_serializedProperties.SubsurfaceColour); m_setter.DrawProperty(Labels.SubsurfaceScatteringPower, m_serializedProperties.SubsurfaceScatteringPower); } } } } m_setter.Update(); GUI.enabled = true; }
/// <summary> /// Enables the user to enhance the source data (e.g. with reconstructed geometry) using external tools. /// </summary> private void SectionExternalTools() { if (ExternalSettings.areExternalToolsLinked) { using (var indentScope = new EditorGUI.IndentLevelScope()) for (int iter = 0; iter < _targetObject.externalHelpers.Length; iter++) { _targetObject.externalHelpers[iter].DisplayEditorFoldout(); } } else { EditorGUILayout.LabelField("No external tool was linked. Add executable paths in the project settings to enable new functionalities!", GeneralToolkit.wordWrapStyle); EditorGUILayout.Space(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); averageFoldout = EditorGUILayout.Foldout(averageFoldout, "Average Element values"); if (averageFoldout) { using (var scope = new EditorGUI.IndentLevelScope(1)) { ExposeAverageValue(() => AverageYoungModulus, x => AverageYoungModulus = x, "AverageYoungModulus"); ExposeAverageValue(() => AverageDensity, x => AverageDensity = x, "AverageDensity"); ExposeAverageValue(() => AverageDamping, x => AverageDamping = x, "AverageDamping"); ExposeAverageValue(() => AverageThickness, x => AverageThickness = x, "AverageThickness"); } } }
static void Drawer_Environment_ClearFlags(UniversalRenderPipelineSerializedCamera p, Editor owner) { EditorGUI.showMixedValue = p.baseCameraSettings.clearFlags.hasMultipleDifferentValues; Rect clearFlagsRect = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(clearFlagsRect, Styles.backgroundType, p.baseCameraSettings.clearFlags); { EditorGUI.BeginChangeCheck(); BackgroundType backgroundType = GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue); var selectedValue = (BackgroundType)EditorGUI.EnumPopup(clearFlagsRect, Styles.backgroundType, backgroundType); if (EditorGUI.EndChangeCheck()) { CameraClearFlags selectedClearFlags; switch (selectedValue) { case BackgroundType.Skybox: selectedClearFlags = CameraClearFlags.Skybox; break; case BackgroundType.DontCare: selectedClearFlags = CameraClearFlags.Nothing; break; default: selectedClearFlags = CameraClearFlags.SolidColor; break; } p.baseCameraSettings.clearFlags.intValue = (int)selectedClearFlags; } if (!p.baseCameraSettings.clearFlags.hasMultipleDifferentValues) { if (GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue) == BackgroundType.SolidColor) { using (var group = new EditorGUI.IndentLevelScope()) { p.baseCameraSettings.DrawBackgroundColor(); } } } } EditorGUI.EndProperty(); EditorGUI.showMixedValue = false; }
/// <summary> /// Enables the user to choose color and geometry processing methods. /// </summary> private void SectionProcessingMethods() { EditorGUILayout.Space(); string label = "Color and geometry processing methods:"; string tooltip = "Choice of color and geometry processing methods."; // Get methods that have a GUI that should be displayed at the topmost level. ProcessingMethod[] allMethods = _targetObject.processingMethods; List <ProcessingMethod> topmostMethods = new List <ProcessingMethod>(); for (int iter = 1; iter < allMethods.Length; iter++) { if (!allMethods[iter].IsGUINested()) { topmostMethods.Add(allMethods[iter]); } } // Check whether one of these methods is compatible. bool[] arrayIsMethodCompatible = new bool[topmostMethods.Count]; bool isThereACompatibleMethod = false; for (int iter = 0; iter < topmostMethods.Count; iter++) { arrayIsMethodCompatible[iter] = topmostMethods[iter].IsCompatible(_targetObject.sourceColorCount, _targetObject.sourcePerViewGeometryCount, _targetObject.sourceGlobalGeometryCount); if (arrayIsMethodCompatible[iter]) { isThereACompatibleMethod = true; } } // If there is a compatible method, display the section enabling to choose a set of processing methods. bool isGUIEnabled = GUI.enabled; GUI.enabled = isGUIEnabled && isThereACompatibleMethod; EditorGUILayout.LabelField(new GUIContent(label, tooltip)); using (var indentScopeOne = new EditorGUI.IndentLevelScope()) { for (int iter = 0; iter < topmostMethods.Count; iter++) { bool isCompatible = arrayIsMethodCompatible[iter]; GUI.enabled = isGUIEnabled && isCompatible; topmostMethods[iter].SectionProcessingMethod(isCompatible); } } GUI.enabled = isGUIEnabled; EditorGUILayout.Space(); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(m_PoseSourceProp, ArmModelStyles.poseSourceLabel); EditorGUILayout.PropertyField(m_HeadGameObjectProp, ArmModelStyles.headPositionSourceLabel); EditorGUILayout.PropertyField(m_ArmExtensionOffsetProp, ArmModelStyles.armExtensionOffsetLabel); EditorGUILayout.PropertyField(m_JointShiftAngleProp, SwingArmModelStyles.jointShiftAngleLabel); EditorGUILayout.PropertyField(m_JointShiftExponentProp, SwingArmModelStyles.jointShiftExponentLabel); EditorGUILayout.PropertyField(m_ElbowBendRatioProp, ArmModelStyles.elbowBendRatioLabel); EditorGUILayout.PropertyField(m_IsLockedToNeckProp, ArmModelStyles.isLockedToNeckLabel); m_ExpandRestPosition = EditorGUILayout.Foldout(m_ExpandRestPosition, ArmModelStyles.restPositionLabel); if (m_ExpandRestPosition) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(m_EblowRestPositionProp, ArmModelStyles.elbowRestPositionLabel); EditorGUILayout.PropertyField(m_WristRestPositionProp, ArmModelStyles.wristRestPositionLabel); EditorGUILayout.PropertyField(m_ControllerRestPositionProp, ArmModelStyles.controllerRestPositionLabel); } } m_ExpandShoulder = EditorGUILayout.Foldout(m_ExpandShoulder, SwingArmModelStyles.rotationRatioLabel); if (m_ExpandShoulder) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(m_ShoulderRotationRatioProp, SwingArmModelStyles.shoulderRotationRatioLabel); EditorGUILayout.PropertyField(m_EblowRotationRatioProp, SwingArmModelStyles.elbowRotationRatioLabel); EditorGUILayout.PropertyField(m_WristRotationRatioProp, SwingArmModelStyles.wristRotationRatioLabel); } } m_ExpandShiftedShoulder = EditorGUILayout.Foldout(m_ExpandShiftedShoulder, SwingArmModelStyles.shiftedRotationRatioLabel); if (m_ExpandShiftedShoulder) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(m_ShiftedShoulderRotationRatioProp, SwingArmModelStyles.shiftedShoulderRotationRatioLabel); EditorGUILayout.PropertyField(m_ShiftedEblowRotationRatioProp, SwingArmModelStyles.shiftedElbowRotationRatioLabel); EditorGUILayout.PropertyField(m_ShiftedWristRotationRatioProp, SwingArmModelStyles.shiftedWristRotationRatioLabel); } } serializedObject.ApplyModifiedProperties(); }
void DrawModelHome() { var homes = IModelHome.GetAllHomes(); var(selectedHome, selectIndex) = homes.Zip(Enumerable.Range(0, homes.Length), (_h, _i) => (home: _h, index: _i)) .FirstOrDefault(_t => _t.home == _selectedHome); var homeNames = homes .Select(_h => GetModelDisplayName(_h.RootModel)) .ToArray(); var newSelected = EditorGUILayout.Popup(_modelHomeLabel, selectIndex, homeNames); if (newSelected != selectIndex) { _selectedHome = homes[newSelected]; } if (_selectedHome == null) { if (!homes.Any()) { return; } _selectedHome = homes.First(); } using (var scrollScope = new EditorGUILayout.ScrollViewScope(_rootScrollPos)) { _rootScrollPos = scrollScope.scrollPosition; using (var indentScope = new EditorGUI.IndentLevelScope()) { if (_selectedHome.RootModel == null) { EditorGUILayout.LabelField($"RootModel is none"); return; } EditorGUILayout.LabelField(_selectedHome.RootModel.GetPath()); DrawModel(_selectedHome.RootModel); } } }
public override void OnInspectorGUI() { m_setter.Clear(); serializedObject.DrawScript(); EditorGUILayout.PropertyField(m_serializedProperties.IsRunning, Labels.IsRunning); if (m_isSettingsOpen = EditorGUILayout.Foldout(m_isSettingsOpen, Labels.Settings, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawFloatSetting(Labels.NormalSmoothing, m_serializedProperties.NormalSmoothing, min: SDFGroup.MIN_SMOOTHING, onValueChangedCallback: m_sdfGroup.OnSettingsChanged); m_setter.DrawFloatSetting(Labels.ThicknessMaxDistance, m_serializedProperties.ThicknessMaxDistance, min: 0f, onValueChangedCallback: m_sdfGroup.OnSettingsChanged); m_setter.DrawFloatSetting(Labels.ThicknessFalloff, m_serializedProperties.ThicknessFalloff, min: 0f, onValueChangedCallback: m_sdfGroup.OnSettingsChanged); } } } m_setter.Update(); }
private ReorderableList getList(SerializedProperty property, string displayName) { ReorderableList list = null; cachedLists.TryGetValue(property.propertyPath, out list); if (list == null) { list = new ReorderableList(property.serializedObject, property, true, true, true, true); list.drawHeaderCallback = (Rect rect) => { var oldLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUI.LabelField(rect, displayName + " (" + property.arraySize + ")"); EditorGUI.indentLevel = oldLevel; }; list.drawElementCallback = (rect, index, isActive, isFocused) => { using (var scope = new EditorGUI.IndentLevelScope(-EditorGUI.indentLevel)) { EditorGUI.LabelField(rect, new GUIContent(index.ToString())); } rect.x += 15; rect.width -= 15; if (property.GetArrayElementAtIndex(index).isExpanded) { var oldColor = GUI.color; GUI.color *= new Color(1, 1, 1, 0.5f); GUI.Box(rect, GUIContent.none); GUI.color = oldColor; rect.width -= 10; } var element = property.GetArrayElementAtIndex(index); if (element.hasVisibleChildren) { EditorGUI.indentLevel++; EditorGUI.PropertyField(rect, element, true); EditorGUI.indentLevel--; } else { int oldLevel = EditorGUI.indentLevel; if (property.depth >= 2) { EditorGUI.indentLevel = 0; } EditorGUI.PropertyField(rect, element, GUIContent.none); if (property.depth >= 2) { EditorGUI.indentLevel = 0; } EditorGUI.indentLevel = oldLevel; } }; list.elementHeightCallback = (int index) => { var element = property.GetArrayElementAtIndex(index); var extra = 0; if (element.isExpanded) { extra += 10; } return(EditorGUI.GetPropertyHeight(element) + extra); }; cachedLists[property.propertyPath] = list; } return(list); }
private void DrawExtension(GExtensionInfo ex) { GUI.enabled = !EditorApplication.isCompiling; string filter = SearchString.ToLower(); if (!ex.Name.ToLower().Contains(filter) && !ex.Publisher.ToLower().Contains(filter) && !ex.Description.ToLower().Contains(filter)) { return; } string id = "griffin-extension" + ex.Name + ex.Publisher; string label = ex.Name; GEditorCommon.Foldout(label, false, id, () => { try { EditorGUILayout.LabelField("Publisher", ex.Publisher); EditorGUILayout.LabelField("Version", ex.Version); EditorGUILayout.LabelField("Description", ex.Description, GEditorCommon.WordWrapLeftLabel); if (ex.OpenUserGuideMethod != null || ex.OpenSupportLinkMethod != null) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Link"); using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1)) { Rect r = EditorGUILayout.GetControlRect(); List <string> linkLabels = new List <string>(); linkLabels.Add("Support"); if (ex.OpenUserGuideMethod != null) { linkLabels.Add("User Guide"); } List <Rect> linkRects = EditorGUIUtility.GetFlowLayoutedRects(r, EditorStyles.label, 7, 0, linkLabels); for (int i = 0; i < linkRects.Count; ++i) { EditorGUIUtility.AddCursorRect(linkRects[i], MouseCursor.Link); } if (GUI.Button(linkRects[0], "Support", EditorStyles.label)) { ex.OpenSupportLinkMethod.Invoke(null, null); } GEditorCommon.DrawBottomLine(linkRects[0], EditorStyles.label.normal.textColor); if (ex.OpenUserGuideMethod != null) { if (GUI.Button(linkRects[1], "User Guide", EditorStyles.label)) { ex.OpenUserGuideMethod.Invoke(null, null); } GEditorCommon.DrawBottomLine(linkRects[1], EditorStyles.label.normal.textColor); } } EditorGUILayout.EndHorizontal(); } if (ex.ButtonMethods.Count > 0) { GEditorCommon.Separator(); for (int i = 0; i < ex.ButtonMethods.Count; ++i) { MethodInfo method = ex.ButtonMethods[i]; if (method == null) { continue; } string buttonLabel = ObjectNames.NicifyVariableName(method.Name.Substring(GExtensionInfo.BUTTON_METHOD_PREFIX.Length)); if (GUILayout.Button(buttonLabel)) { method.Invoke(null, null); } } } if (ex.GuiMethod != null) { GEditorCommon.Separator(); ex.GuiMethod.Invoke(null, null); } } catch (System.Exception e) { EditorGUILayout.LabelField(string.Format("<color=red>Error: {0}</color>", e.ToString()), GEditorCommon.RichTextLabel); Debug.LogException(e); } }); 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(); }
/// <summary> /// Override implementation of <a href="https://docs.unity3d.com/ScriptReference/Editor.OnInspectorGUI.html">Editor.OnInspectorGUI</a> /// to draw the inspector GUI for the currently selected <see cref="WebcamSource"/>. /// </summary> public override void OnInspectorGUI() { // CalcSize() can only be called inside a GUI method if (_anyWidth < 0) { _anyWidth = GUI.skin.label.CalcSize(_anyContent).x; } if (_unitWidth < 0) { _unitWidth = GUI.skin.label.CalcSize(new GUIContent("fps")).x; } serializedObject.Update(); if (!PlayerSettings.WSA.GetCapability(PlayerSettings.WSACapability.WebCam)) { EditorGUILayout.HelpBox("The UWP player is missing the WebCam capability. The WebcamSource component will not function correctly." + " Add the WebCam capability in Project Settings > Player > UWP > Publishing Settings > Capabilities.", MessageType.Error); if (GUILayout.Button("Open Player Settings")) { SettingsService.OpenProjectSettings("Project/Player"); } if (GUILayout.Button("Add WebCam Capability")) { PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.WebCam, true); } } GUILayout.Space(10); EditorGUILayout.LabelField("Video capture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_formatMode, new GUIContent("Capture format", "Decide how to obtain the constraints used to select the best capture format.")); if ((LocalVideoSourceFormatMode)_formatMode.intValue == LocalVideoSourceFormatMode.Manual) { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.LabelField("General constraints (all platforms)"); using (new EditorGUI.IndentLevelScope()) { OptionalIntField(_width, ref _prevWidth, new GUIContent("Width", "Only consider capture formats with the specified width."), new GUIContent("px", "Pixels")); OptionalIntField(_height, ref _prevHeight, new GUIContent("Height", "Only consider capture formats with the specified height."), new GUIContent("px", "Pixels")); OptionalDoubleField(_framerate, ref _prevFramerate, new GUIContent("Framerate", "Only consider capture formats with the specified framerate."), new GUIContent("fps", "Frames per second")); } EditorGUILayout.LabelField("UWP constraints"); using (new EditorGUI.IndentLevelScope()) { OptionalEnumField(_videoProfileKind, VideoProfileKind.Unspecified, ref _prevVideoProfileKind, new GUIContent("Video profile kind", "Only consider capture formats associated with the specified video profile kind.")); OptionalTextField(_videoProfileId, ref _prevVideoProfileId, new GUIContent("Video profile ID", "Only consider capture formats associated with the specified video profile.")); if ((_videoProfileKind.intValue != (int)VideoProfileKind.Unspecified) && (_videoProfileId.stringValue.Length > 0)) { EditorGUILayout.HelpBox("Video profile ID is already unique. Specifying also a video kind over-constrains the selection algorithm and can decrease the chances of finding a matching video profile. It is recommended to select either a video profile kind, or a video profile ID.", MessageType.Warning); } } } } _enableMixedRealityCapture.boolValue = EditorGUILayout.ToggleLeft("Enable Mixed Reality Capture (MRC)", _enableMixedRealityCapture.boolValue); if (_enableMixedRealityCapture.boolValue) { using (var scope = new EditorGUI.IndentLevelScope()) { _enableMrcRecordingIndicator.boolValue = EditorGUILayout.ToggleLeft("Show recording indicator in device", _enableMrcRecordingIndicator.boolValue); if (!PlayerSettings.virtualRealitySupported) { EditorGUILayout.HelpBox("Mixed Reality Capture can only work in exclusive-mode apps. XR support must be enabled in Project Settings > Player > XR Settings > Virtual Reality Supported, and the project then saved to disk.", MessageType.Error); if (GUILayout.Button("Enable XR support")) { PlayerSettings.virtualRealitySupported = true; } } } } GUILayout.Space(10); EditorGUILayout.PropertyField(_videoStreamStarted); EditorGUILayout.PropertyField(_videoStreamStopped); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { var inst = target as LayoutTargetComponent; if (inst.transform is RectTransform) { FollowRectTransform = EditorGUILayout.Toggle("Follow RectTransform?", FollowRectTransform); if (FollowRectTransform) { inst.AutoDetectUpdater(); inst.CopyToLayoutTarget(); } } if (opModePopUp.Draw(new GUIContent("OpMode"))) { CurrentOpMode = opModePopUp.SelectedOpMode; } var propSP = serializedObject.FindProperty("_target"); var enterChildProps = true; while (propSP.NextVisible(enterChildProps)) { if (0 != (PropertyOpModeDict[propSP.name] & CurrentOpMode)) { EditorGUILayout.PropertyField(propSP); } enterChildProps = false; } if (0 != (CurrentOpMode & OpMode.Anchor)) { _foldoutAnchorTypePreset = EditorGUILayout.Foldout(_foldoutAnchorTypePreset, "Anchor Min/Max Preset"); if (_foldoutAnchorTypePreset) { using (var indentScope = new EditorGUI.IndentLevelScope()) { foreach (var presetType in _anchorPresetTypes) { using (var scope = new EditorGUILayout.HorizontalScope()) { var targetSP = serializedObject.FindProperty("_target"); var anchorMinSP = targetSP.FindPropertyRelative("_anchorMin"); var anchorMaxSP = targetSP.FindPropertyRelative("_anchorMax"); var localSizeSP = targetSP.FindPropertyRelative("_localSize"); var newAnchorType = (AnchorPresetType)EditorGUILayout.EnumPopup(presetType.Name, presetType.Type); if (presetType.Type != newAnchorType) { presetType.Type = newAnchorType; var elementMinSP = anchorMinSP.FindPropertyRelative(presetType.Name); var elementMaxSP = anchorMaxSP.FindPropertyRelative(presetType.Name); switch (presetType.Type) { case AnchorPresetType.Low: elementMinSP.floatValue = 0f; elementMaxSP.floatValue = 0f; break; case AnchorPresetType.Middle: elementMinSP.floatValue = 0.5f; elementMaxSP.floatValue = 0.5f; break; case AnchorPresetType.High: elementMinSP.floatValue = 1f; elementMaxSP.floatValue = 1f; break; case AnchorPresetType.Expand: elementMinSP.floatValue = 0f; elementMaxSP.floatValue = 1f; break; } } var anchorAreaSize = GetLayoutSize(this.target as LayoutTargetComponent); var doExpand = MathUtils.AreNearlyEqual(anchorAreaSize[presetType.ElementIndex], localSizeSP.vector3Value[presetType.ElementIndex], LayoutDefines.NUMBER_PRECISION); var newDoExpand = EditorGUILayout.Toggle("doExpand?", doExpand); if (newDoExpand != doExpand && newDoExpand) { var layoutSize = GetLayoutSize(this.target as LayoutTargetComponent); var tmp = localSizeSP.vector3Value; tmp[presetType.ElementIndex] = layoutSize[presetType.ElementIndex]; localSizeSP.vector3Value = tmp; var offsetMinSP = targetSP.FindPropertyRelative("_anchorOffsetMin"); var offsetMin = offsetMinSP.vector3Value; var offsetMaxSP = targetSP.FindPropertyRelative("_anchorOffsetMax"); var offsetMax = offsetMaxSP.vector3Value; offsetMin[presetType.ElementIndex] = 0; offsetMax[presetType.ElementIndex] = 0; offsetMinSP.vector3Value = offsetMin; offsetMaxSP.vector3Value = offsetMax; } } } } } _foldoutAnchorOffset = EditorGUILayout.Foldout(_foldoutAnchorOffset, "Anchor Offset Min/Max"); if (_foldoutAnchorOffset && false) { using (var s = new EditorGUI.IndentLevelScope()) { var targetSP = serializedObject.FindProperty("_target"); var anchorMinSP = targetSP.FindPropertyRelative("_anchorMin"); var anchorMaxSP = targetSP.FindPropertyRelative("_anchorMax"); var localSizeSP = targetSP.FindPropertyRelative("_localSize"); var offsetSP = targetSP.FindPropertyRelative("_offset"); var other = new LayoutTargetObject(); other.SetParent(GetParentLayoutTarget(inst)); other.Pivot = inst.LayoutTarget.Pivot; other.SetAnchor(inst.LayoutTarget.AnchorMin, inst.LayoutTarget.AnchorMax); other.UpdateLocalSize(inst.LayoutTarget.LocalSize, inst.LayoutTarget.Offset); var(offsetMin, offsetMax) = other.AnchorOffsetMinMax(); var newOffsetMin = EditorGUILayout.Vector3Field("Offset Min", offsetMin); var newOffsetMax = EditorGUILayout.Vector3Field("Offset Max", offsetMax); if (!offsetMin.AreNearlyEqual(newOffsetMin) || !offsetMax.AreNearlyEqual(newOffsetMax)) { other.SetAnchorOffset(newOffsetMin, newOffsetMax); anchorMinSP.vector3Value = other.AnchorMin; anchorMaxSP.vector3Value = other.AnchorMax; localSizeSP.vector3Value = other.LocalSize; offsetSP.vector3Value = other.Offset; other.Dispose(); } } } } if (serializedObject.ApplyModifiedProperties()) { LayoutManagerEditor.UpdateLayoutHierachy(inst); } if (GUILayout.Button("Copy From Transform")) { inst.CopyToLayoutTarget(); } }
/// <summary> /// Override implementation of <a href="https://docs.unity3d.com/ScriptReference/Editor.OnInspectorGUI.html">Editor.OnInspectorGUI</a> /// to draw the inspector GUI for the currently selected <see cref="WebcamSource"/>. /// </summary> public override void OnInspectorGUI() { // CalcSize() can only be called inside a GUI method if (_anyWidth < 0) { _anyWidth = GUI.skin.label.CalcSize(_anyContent).x; } if (_unitWidth < 0) { _unitWidth = GUI.skin.label.CalcSize(new GUIContent("fps")).x; } serializedObject.Update(); GUILayout.Space(10); EditorGUILayout.LabelField("Video capture", EditorStyles.boldLabel); ToggleLeft(_autoStartOnEnabled, new GUIContent("Start capture when enabled", "Automatically start video capture when this component is enabled.")); EditorGUILayout.PropertyField(_formatMode, new GUIContent("Capture format", "Decide how to obtain the constraints used to select the best capture format.")); if ((LocalVideoSourceFormatMode)_formatMode.intValue == LocalVideoSourceFormatMode.Manual) { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.LabelField("General constraints (all platforms)"); using (new EditorGUI.IndentLevelScope()) { OptionalIntField(_width, ref _prevWidth, new GUIContent("Width", "Only consider capture formats with the specified width."), new GUIContent("px", "Pixels")); OptionalIntField(_height, ref _prevHeight, new GUIContent("Height", "Only consider capture formats with the specified height."), new GUIContent("px", "Pixels")); OptionalDoubleField(_framerate, ref _prevFramerate, new GUIContent("Framerate", "Only consider capture formats with the specified framerate."), new GUIContent("fps", "Frames per second")); } EditorGUILayout.LabelField("UWP constraints"); using (new EditorGUI.IndentLevelScope()) { OptionalEnumField(_videoProfileKind, VideoProfileKind.Unspecified, ref _prevVideoProfileKind, new GUIContent("Video profile kind", "Only consider capture formats associated with the specified video profile kind.")); OptionalTextField(_videoProfileId, ref _prevVideoProfileId, new GUIContent("Video profile ID", "Only consider capture formats associated with the specified video profile.")); if ((_videoProfileKind.intValue != (int)VideoProfileKind.Unspecified) && (_videoProfileId.stringValue.Length > 0)) { EditorGUILayout.HelpBox("Video profile ID is already unique. Specifying also a video kind over-constrains the selection algorithm and can decrease the chances of finding a matching video profile. It is recommended to select either a video profile kind, or a video profile ID.", MessageType.Warning); } } } } _enableMixedRealityCapture.boolValue = EditorGUILayout.ToggleLeft("Enable Mixed Reality Capture (MRC)", _enableMixedRealityCapture.boolValue); if (_enableMixedRealityCapture.boolValue) { using (var scope = new EditorGUI.IndentLevelScope()) { _enableMrcRecordingIndicator.boolValue = EditorGUILayout.ToggleLeft("Show recording indicator in device", _enableMrcRecordingIndicator.boolValue); if (!PlayerSettings.virtualRealitySupported) { EditorGUILayout.HelpBox("Mixed Reality Capture can only work in exclusive-mode apps. XR support must be enabled in Project Settings > Player > XR Settings > Virtual Reality Supported, and the project then saved to disk.", MessageType.Error); if (GUILayout.Button("Enable XR support")) { PlayerSettings.virtualRealitySupported = true; } } } } EditorGUILayout.PropertyField(_videoStreamStarted); EditorGUILayout.PropertyField(_videoStreamStopped); GUILayout.Space(10); EditorGUILayout.LabelField("WebRTC track", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_trackName); var rect = EditorGUILayout.GetControlRect(); using (new EditorGUI.PropertyScope(rect, new GUIContent(), _preferredVideoCodec)) { // Convert the selected codec name to an enum value. // This may throw an exception if this is a custom name, which will be handled below. SdpVideoCodecs codecValue; string customCodecValue = string.Empty; if (_preferredVideoCodec.stringValue.Length == 0) { codecValue = SdpVideoCodecs.None; } else { try { codecValue = (SdpVideoCodecs)Enum.Parse(typeof(SdpVideoCodecs), _preferredVideoCodec.stringValue); } catch { codecValue = SdpVideoCodecs.Custom; customCodecValue = _preferredVideoCodec.stringValue; // Hide internal marker if (customCodecValue == "__CUSTOM") { customCodecValue = string.Empty; } } } // Display the edit field for the enum var newCodecValue = (SdpVideoCodecs)EditorGUI.EnumPopup(rect, _preferredVideoCodec.displayName, codecValue); if (newCodecValue == SdpVideoCodecs.H264) { EditorGUILayout.HelpBox("H.264 is only supported on UWP platforms.", MessageType.Warning); } // Update the value if changed or custom if ((newCodecValue != codecValue) || (newCodecValue == SdpVideoCodecs.Custom)) { if (newCodecValue == SdpVideoCodecs.None) { _preferredVideoCodec.stringValue = string.Empty; } else if (newCodecValue == SdpVideoCodecs.Custom) { ++EditorGUI.indentLevel; string newValue = EditorGUILayout.TextField("SDP codec name", customCodecValue); if (newValue == string.Empty) { EditorGUILayout.HelpBox("The SDP codec name must be non-empty. See https://en.wikipedia.org/wiki/RTP_audio_video_profile for valid names.", MessageType.Error); // Force a non-empty value now, otherwise the field will reset to None newValue = "__CUSTOM"; } _preferredVideoCodec.stringValue = newValue; --EditorGUI.indentLevel; } else { _preferredVideoCodec.stringValue = Enum.GetName(typeof(SdpVideoCodecs), newCodecValue); } } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.DrawScript(); m_setter.Clear(); m_setter.DrawProperty(Labels.Type, m_serializedProperties.Type); m_setter.DrawProperty(Labels.Operation, m_serializedProperties.Operation); m_setter.DrawProperty(Labels.Flip, m_serializedProperties.Flip); m_setter.DrawFloatSetting(Labels.Smoothing, m_serializedProperties.Smoothing, min: 0f); using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { switch (m_sdfPrimitive.Type) { case SDFPrimitiveType.Sphere: m_setter.DrawVectorSettingX(Labels.Radius, m_serializedProperties.Data, min: 0f); break; case SDFPrimitiveType.Torus: m_setter.DrawVectorSettingX(Labels.MajorRadius, m_serializedProperties.Data, min: 0f); m_setter.DrawVectorSettingY(Labels.MinorRadius, m_serializedProperties.Data, min: 0f); break; case SDFPrimitiveType.Cuboid: m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f); m_setter.DrawVectorSettingW(Labels.Roundedness, m_serializedProperties.Data, min: 0f); break; case SDFPrimitiveType.BoxFrame: m_setter.DrawVector3Setting(Labels.Bounds, m_serializedProperties.Data, min: 0f); m_setter.DrawVectorSettingW(Labels.Thickness, m_serializedProperties.Data, min: 0f); break; case SDFPrimitiveType.Cylinder: m_setter.DrawVectorSettingX(Labels.CylinderRadius, m_serializedProperties.Data, min: 0f); m_setter.DrawVectorSettingY(Labels.CylinderLength, m_serializedProperties.Data, min: 0f); break; } } if (m_isMaterialOpen = EditorGUILayout.Foldout(m_isMaterialOpen, Labels.Material, true)) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_setter.DrawProperty(Labels.MaterialType, m_serializedProperties.MaterialType); if (m_sdfPrimitive.Material.Type != SDFMaterial.MaterialType.None) { if (m_sdfPrimitive.Material.Type == SDFMaterial.MaterialType.Texture) { m_setter.DrawProperty(Labels.MaterialTexture, m_serializedProperties.MaterialTexture); } m_setter.DrawProperty(Labels.Colour, m_serializedProperties.Colour); m_setter.DrawFloatSetting(Labels.MaterialSmoothing, m_serializedProperties.MaterialSmoothing, min: 0f); m_setter.DrawProperty(Labels.Emission, m_serializedProperties.Emission); m_setter.DrawProperty(Labels.Metallic, m_serializedProperties.Metallic); m_setter.DrawProperty(Labels.Smoothness, m_serializedProperties.Smoothness); m_setter.DrawProperty(Labels.SubsurfaceColour, m_serializedProperties.SubsurfaceColour); m_setter.DrawProperty(Labels.SubsurfaceScatteringPower, m_serializedProperties.SubsurfaceScatteringPower); } } } } m_setter.Update(); }
public override void OnInspectorGUI() { m_setter.Clear(); //Debug.Log(m_grid.VoxelSettings.Extents); //Debug.Log(m_grid.VoxelSettings.Radius); serializedObject.DrawScript(); m_setter.DrawProperty(Labels.SDFGroup, m_serializedProperties.SDFGroup); bool hasGroup = m_serializedProperties.SDFGroup.objectReferenceValue; if (!hasGroup) { EditorGUILayout.HelpBox(Labels.GroupRequiredError, MessageType.Error); } GUI.enabled = hasGroup; m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_grid.OnMainSettingsChanged); OutputMode outputMode = (OutputMode)m_serializedProperties.OutputMode.enumValueIndex; if (outputMode == OutputMode.Procedural) { m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial, onValueChangedCallback: m_grid.OnMainSettingsChanged); } else if (outputMode == OutputMode.MeshFilter) { m_setter.DrawProperty(Labels.AddMeshRenderers, m_serializedProperties.AddMeshRenderers); if (m_serializedProperties.AddMeshRenderers.boolValue) { m_setter.DrawProperty(Labels.MeshRendererMaterial, m_serializedProperties.MeshRendererMaterial); } m_setter.DrawProperty(Labels.AddMeshColliders, m_serializedProperties.AddMeshColliders); m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous, onValueChangedCallback: m_grid.OnMainSettingsChanged); } 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_grid.OnVoxelSettingChanged); m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_grid.OnVoxelSettingChanged); } else if (cellSizeMode == CellSizeMode.Density) { m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_grid.OnVoxelSettingChanged); m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_grid.OnVoxelSettingChanged); } } } } 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_grid.OnAlgorithmSettingsChanged); if ((IsosurfaceExtractionType)m_serializedProperties.IsosurfaceExtractionType.enumValueIndex == IsosurfaceExtractionType.DualContouring) { m_setter.DrawFloatSetting(Labels.ConstrainToCellUnits, m_serializedProperties.ConstrainToCellUnits, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel); m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); if ((IsosurfaceExtractionType)m_serializedProperties.IsosurfaceExtractionType.enumValueIndex == IsosurfaceExtractionType.DualContouring) { EditorGUILayout.Space(); EditorGUILayout.LabelField("QEF Settings", EditorStyles.boldLabel); m_setter.DrawBoolSetting(Labels.OverrideQEFSettings, m_serializedProperties.OverrideQEFSettings, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); if (m_serializedProperties.OverrideQEFSettings.boolValue) { m_setter.DrawIntSetting(Labels.QEFSweeps, m_serializedProperties.QEFSweeps, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); m_setter.DrawFloatSetting(Labels.QEFPseudoInverseThreshold, m_serializedProperties.QEFPseudoInverseThreshold, min: 1e-7f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Nudge Settings", EditorStyles.boldLabel); m_setter.DrawFloatSetting(Labels.NudgeVerticesToAverageNormalScalar, m_serializedProperties.NudgeVerticesToAverageNormalScalar, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); m_setter.DrawFloatSetting(Labels.NudgeMaxMagnitude, m_serializedProperties.NudgeMaxMagnitude, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel); m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); if ((EdgeIntersectionType)m_serializedProperties.EdgeIntersectionType.enumValueIndex == EdgeIntersectionType.BinarySearch) { m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel); m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); if (m_serializedProperties.ApplyGradientDescent.boolValue) { m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged); } } } } GUI.enabled = true; m_setter.Update(); }
private void DrawFilterLayer(GTextureFilterLayer layer, int index) { string label = string.Format("{0} {1}", ObjectNames.NicifyVariableName(layer.Type.ToString()), layer.Enabled ? "" : "[-]"); string id = "texture-creator-filter" + index; string prefKey = GEditorCommon.GetProjectRelatedEditorPrefsKey("foldout", id); bool expanded = EditorPrefs.GetBool(prefKey, true); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; Rect headerRect = EditorGUILayout.BeginHorizontal(); expanded = EditorGUILayout.Foldout(expanded, label); EditorPrefs.SetBool(prefKey, expanded); GUILayout.FlexibleSpace(); Rect deleteButtonRect = EditorGUILayout.GetControlRect(GUILayout.Width(15)); if (headerRect.Contains(Event.current.mousePosition)) { if (GUI.Button(deleteButtonRect, "X", EditorStyles.label)) { ConfirmAndRemoveFilterAt(index); } } EditorGUILayout.EndHorizontal(); if (expanded) { EditorGUI.indentLevel += 1; layer.Enabled = EditorGUILayout.Toggle("Enable", layer.Enabled); GTextureFilterParams param = layer.Param; if (layer.Type == GTextureFilterType.Blur) { GBlurParams blur = param.Blur; blur.Radius = EditorGUILayout.DelayedIntField("Radius", blur.Radius); EditorGUILayout.LabelField("This filter is expensive!", GEditorCommon.WordWrapItalicLabel); param.Blur = blur; } else if (layer.Type == GTextureFilterType.Curve) { GCurveParams curve = param.Curve; curve.MasterCurve = EditorGUILayout.CurveField("Master", curve.MasterCurve, Color.white, GCommon.UnitRect); curve.RedCurve = EditorGUILayout.CurveField("Red", curve.RedCurve, Color.red, GCommon.UnitRect); curve.GreenCurve = EditorGUILayout.CurveField("Green", curve.GreenCurve, Color.green, GCommon.UnitRect); curve.BlueCurve = EditorGUILayout.CurveField("Blue", curve.BlueCurve, Color.blue, GCommon.UnitRect); curve.AlphaCurve = EditorGUILayout.CurveField("Alpha", curve.AlphaCurve, Color.gray, GCommon.UnitRect); param.Curve = curve; } else if (layer.Type == GTextureFilterType.Invert) { GInvertParams invert = param.Invert; invert.InvertRed = EditorGUILayout.Toggle("Red", invert.InvertRed); invert.InvertGreen = EditorGUILayout.Toggle("Green", invert.InvertGreen); invert.InvertBlue = EditorGUILayout.Toggle("Blue", invert.InvertBlue); invert.InvertAlpha = EditorGUILayout.Toggle("Alpha", invert.InvertAlpha); param.Invert = invert; } else if (layer.Type == GTextureFilterType.Step) { GStepParams step = param.Step; step.Count = EditorGUILayout.IntSlider("Count", step.Count, 1, 256); param.Step = step; } else if (layer.Type == GTextureFilterType.Warp) { GWarpParams warp = param.Warp; warp.MaskIsNormalMap = EditorGUILayout.Toggle("Is Normal Map", warp.MaskIsNormalMap); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Mask"); using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1)) { warp.Mask = EditorGUILayout.ObjectField(warp.Mask, typeof(Texture2D), false) as Texture2D; } EditorGUILayout.EndHorizontal(); warp.Strength = EditorGUILayout.FloatField("Strength", warp.Strength); param.Warp = warp; } /* * else if (layer.Type == GTextureFilterType.HydraulicErosion) * { * GHydraulicErosionParams erosion = param.HydraulicErosion; * * erosion.Iteration = EditorGUILayout.IntField("Iteration", erosion.Iteration); * * Vector3 dim = erosion.Dimension; * dim = GEditorCommon.InlineVector3Field("Dimension", dim); * dim.Set(Mathf.Max(1, dim.x), Mathf.Max(1, dim.y), Mathf.Max(1, dim.z)); * erosion.Dimension = dim; * * erosion.Rain = EditorGUILayout.Slider("Rain", erosion.Rain, 0f, 1f); * erosion.Transportation = EditorGUILayout.Slider("Transportation", erosion.Transportation, 0f, 1f); * erosion.AngleMin = EditorGUILayout.Slider("Min Angle", erosion.AngleMin, 1f, 45f); * erosion.Evaporation = EditorGUILayout.Slider("Evaporation", erosion.Evaporation, 0f, 1f); * * EditorGUILayout.BeginHorizontal(); * EditorGUILayout.PrefixLabel("Water Source"); * using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1)) * { * erosion.WaterSourceMap = EditorGUILayout.ObjectField(erosion.WaterSourceMap, typeof(Texture2D), false) as Texture2D; * } * EditorGUILayout.EndHorizontal(); * * EditorGUILayout.BeginHorizontal(); * EditorGUILayout.PrefixLabel("Hardness"); * using (EditorGUI.IndentLevelScope level = new EditorGUI.IndentLevelScope(-1)) * { * erosion.HardnessMap = EditorGUILayout.ObjectField(erosion.HardnessMap, typeof(Texture2D), false) as Texture2D; * } * EditorGUILayout.EndHorizontal(); * * param.HydraulicErosion = erosion; * } */ layer.Param = param; EditorGUI.indentLevel -= 1; } EditorGUI.indentLevel = indent; }
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; }
private void OnGUI() { using (EditorGUILayout.ScrollViewScope scroll = new EditorGUILayout.ScrollViewScope(m_scrollPos)) { m_scrollPos = scroll.scrollPosition; Mesh newMesh = (Mesh)EditorGUILayout.ObjectField("Mesh", m_mesh, typeof(Mesh), allowSceneObjects: false); if (m_mesh != newMesh) { m_mesh = newMesh; if (m_inputMeshPreview != null) { DestroyImmediate(m_inputMeshPreview); m_inputMeshPreview = null; } } if (m_mesh != null) { if (m_inputMeshPreview == null) { m_inputMeshPreview = UnityEditor.Editor.CreateEditor(m_mesh); } m_inputMeshPreview.DrawPreview(GUILayoutUtility.GetRect(200, 200)); } m_size = Mathf.Max(1, EditorGUILayout.IntField("Size", m_size)); m_padding = Mathf.Max(0f, EditorGUILayout.FloatField("Padding", m_padding)); //this.DrawIntField("Size", ref m_size, min: 1); ////this.DrawFloatField("Padding", ref m_padding, out _, min: 0f); //this.DrawFloatField("Padding", m_serializedProperties.Padding, out m_padding, min: 0f); m_transformBoxOpened = EditorGUILayout.Foldout(m_transformBoxOpened, "Transform", true); if (m_transformBoxOpened) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { m_translation = EditorGUILayout.Vector3Field("Translation", m_translation); m_rotation = EditorGUILayout.Vector3Field("Rotation", m_rotation); m_scale = EditorGUILayout.Vector3Field("Scale", m_scale); } } } m_tesselateMesh = EditorGUILayout.Toggle("Tessellate Mesh First", m_tesselateMesh); m_sampleUVs = EditorGUILayout.Toggle("Sample UVs", m_tesselateMesh); if (m_tesselateMesh) { using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope()) { if (m_tessellatedMesh != null) { if (m_tesselatedMeshPreview != null && m_tesselatedMeshPreview.serializedObject.targetObject as Mesh != m_tessellatedMesh) { DestroyImmediate(m_tesselatedMeshPreview); m_tesselatedMeshPreview = null; } if (m_tesselatedMeshPreview == null) { m_tesselatedMeshPreview = UnityEditor.Editor.CreateEditor(m_tessellatedMesh); } m_tesselatedMeshPreview.DrawPreview(GUILayoutUtility.GetRect(200, 200)); } m_subdivisions = Mathf.Clamp(EditorGUILayout.IntField("Subdivisions", m_subdivisions), 0, 4); m_minimumEdgeLength = Mathf.Max(EditorGUILayout.FloatField("Minimum Edge Length", m_minimumEdgeLength), 0f); //this.DrawIntField("Subdivisions", ref m_subdivisions, min: 0, max: 4); ////this.DrawFloatField("Minimum Edge Length", ref m_minimumEdgeLength, min: 0); //this.DrawFloatField("Minimum Edge Length", m_serializedProperties.MinimumEdgeLength, out m_minimumEdgeLength, min: 0f); } } } m_autosaveOnComplete = EditorGUILayout.Toggle("Autosave On Complete", m_autosaveOnComplete); //this.DrawBoolField("Autosave On Complete", ref m_autosaveOnComplete); GUI.enabled = m_mesh != null; if (GUI.Button(GUILayoutUtility.GetRect(200, 80), "Generate")) { Generate(); } if (GUI.Button(GUILayoutUtility.GetRect(200, 80), "Save")) { Save(); } GUI.enabled = true; } }