public void SliderField(ref UndoParentNode owner, string content, float min, float max) { if (!m_active) { EditorGUILayout.BeginHorizontal(); m_value = owner.EditorGUILayoutSlider(content, m_value, min, max); if (GUILayout.Button(UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width(15), GUILayout.Height(15))) { m_active = !m_active; } EditorGUILayout.EndHorizontal(); } else { DrawPicker(ref owner, content); } }
public void Draw(UndoParentNode owner) { if (m_isVisible) { int lastOption = m_currentOption; EditorGUI.BeginChangeCheck(); switch (m_options.UIWidget) { case AseOptionsUIWidget.Dropdown: { m_currentOption = owner.EditorGUILayoutPopup(m_options.Name, m_currentOption, m_options.DisplayOptions); } break; case AseOptionsUIWidget.Toggle: { m_currentOption = owner.EditorGUILayoutToggle(m_options.Name, m_currentOption == 1) ? 1 : 0; } break; case AseOptionsUIWidget.Float: { if (m_options.FieldInline) { m_options.FieldValue.FloatField(ref owner, m_options.Name); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutFloatField(m_options.Name, m_options.FieldValue.FloatValue); } } break; case AseOptionsUIWidget.Int: { if (m_options.FieldInline) { m_options.FieldValue.IntField(ref owner, m_options.Name); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutIntField(m_options.Name, (int)m_options.FieldValue.FloatValue); } } break; case AseOptionsUIWidget.FloatRange: { if (m_options.FieldInline) { m_options.FieldValue.SliderField(ref owner, m_options.Name, m_options.FieldMin, m_options.FieldMax); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutSlider(m_options.Name, m_options.FieldValue.FloatValue, m_options.FieldMin, m_options.FieldMax); } } break; case AseOptionsUIWidget.IntRange: { if (m_options.FieldInline) { m_options.FieldValue.IntSlider(ref owner, m_options.Name, (int)m_options.FieldMin, (int)m_options.FieldMax); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutIntSlider(m_options.Name, (int)m_options.FieldValue.FloatValue, (int)m_options.FieldMin, (int)m_options.FieldMax); } } break; } if (EditorGUI.EndChangeCheck()) { if (OnActionPerformedEvt != null) { if (m_invertActionOnDeselection) { OnActionPerformedEvt(false, lastOption != m_options.DisableIdx, this, m_options.ActionsPerOption[lastOption]); } OnActionPerformedEvt(false, false, this, m_options.ActionsPerOption[m_currentOption]); } } } }
//private int m_orderIndex = 1000; public void Draw(UndoParentNode owner, GUIStyle toolbarstyle, Material mat, bool connectedInput) { Color cachedColor = GUI.color; GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, 0.5f); EditorGUILayout.BeginHorizontal(toolbarstyle); GUI.color = cachedColor; EditorGUI.BeginChangeCheck(); m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation = GUILayout.Toggle(m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation, " Tessellation", UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool("ExpandedTesselation", m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation); } EditorGUI.BeginChangeCheck(); m_enabled = owner.EditorGUILayoutToggle(string.Empty, m_enabled, UIUtils.MenuItemEnableStyle, GUILayout.Width(16)); if (EditorGUI.EndChangeCheck()) { if (m_enabled) { UpdateToMaterial(mat, !connectedInput); } UIUtils.RequestSave(); } EditorGUILayout.EndHorizontal(); m_enabled = m_enabled || connectedInput; if (m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation) { cachedColor = GUI.color; GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, (EditorGUIUtility.isProSkin ? 0.5f : 0.25f)); EditorGUILayout.BeginVertical(UIUtils.MenuItemBackgroundStyle); GUI.color = cachedColor; EditorGUILayout.Separator(); EditorGUI.BeginDisabledGroup(!m_enabled); EditorGUI.indentLevel += 1; m_phongEnabled = owner.EditorGUILayoutToggle(PhongEnableContent, m_phongEnabled); if (m_phongEnabled) { EditorGUI.indentLevel += 1; EditorGUI.BeginChangeCheck(); m_phongStrength = owner.EditorGUILayoutSlider(PhongStrengthContent, m_phongStrength, 0.0f, 1.0f); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(PhongStrengthUniformName)) { mat.SetFloat(PhongStrengthUniformName, m_phongStrength); } } EditorGUI.indentLevel -= 1; } bool guiEnabled = GUI.enabled; GUI.enabled = !connectedInput && m_enabled; m_tessType = owner.EditorGUILayoutIntPopup(TesselationTypeStr, m_tessType, TesselationTypeLabels, TesselationTypeValues); switch (m_tessType) { case 0: { EditorGUI.BeginChangeCheck(); m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(TessUniformName)) { mat.SetFloat(TessUniformName, m_tessFactor); } } EditorGUI.BeginChangeCheck(); m_tessMinDistance = owner.EditorGUILayoutFloatField(TessMinDistanceContent, m_tessMinDistance); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(TessMinUniformName)) { mat.SetFloat(TessMinUniformName, m_tessMinDistance); } } EditorGUI.BeginChangeCheck(); m_tessMaxDistance = owner.EditorGUILayoutFloatField(TessMaxDistanceContent, m_tessMaxDistance); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(TessMaxUniformName)) { mat.SetFloat(TessMaxUniformName, m_tessMaxDistance); } } } break; case 1: { EditorGUI.BeginChangeCheck(); m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(TessUniformName)) { mat.SetFloat(TessUniformName, m_tessFactor); } } } break; case 2: { EditorGUI.BeginChangeCheck(); m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(EdgeLengthTessUniformName)) { mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor); } } } break; case 3: { EditorGUI.BeginChangeCheck(); m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(EdgeLengthTessUniformName)) { mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor); } } EditorGUI.BeginChangeCheck(); m_tessMaxDistance = owner.EditorGUILayoutFloatField(EdgeLengthTessMaxDisplacementContent, m_tessMaxDistance); if (EditorGUI.EndChangeCheck() && mat != null) { if (mat.HasProperty(TessMinUniformName)) { mat.SetFloat(TessMinUniformName, m_tessMaxDistance); } } } break; } GUI.enabled = guiEnabled; EditorGUI.indentLevel -= 1; EditorGUI.EndDisabledGroup(); EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); } }