public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties) { FindProperties(properties); bool isToonyHighlightsEnabled; EditorGUILayout.Space(); TSFunctions.DrawSelector(Enum.GetNames(typeof(Workflow)), _workflow, Styles.workflow, materialEditor); if ((Workflow)_workflow.floatValue == Workflow.Metallic) { if (level == InspectorLevel.Normal) { Rect r = TSFunctions.GetControlRectForSingleLine(); EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertyMiniThumbnail(r, _MetallicMap, Styles.metallic.text, Styles.metallic.tooltip); if (EditorGUI.EndChangeCheck()) { inspector.RegenerateMSOT(); } TSFunctions.ProperSlider(MaterialEditor.GetRectAfterLabelWidth(r), ref _Metallic); } else { materialEditor.ShaderProperty(_Metallic, Styles.metallic); } } else if ((Workflow)_workflow.floatValue == Workflow.Specular) { materialEditor.TexturePropertySingleLine(Styles.specular, _MetallicMap); } if (level == InspectorLevel.Normal) { Rect r = TSFunctions.GetControlRectForSingleLine(); EditorGUI.BeginChangeCheck(); materialEditor.TexturePropertyMiniThumbnail(r, _GlossinessMap, Styles.smoothness.text, Styles.smoothness.tooltip); if (EditorGUI.EndChangeCheck()) { inspector.RegenerateMSOT(); } TSFunctions.ProperSlider(MaterialEditor.GetRectAfterLabelWidth(r), ref _Glossiness); } else { materialEditor.ShaderProperty(_Glossiness, Styles.smoothness); } TSFunctions.DrawSelector(Enum.GetNames(typeof(SpMode)), _SpMode, Styles.spMode, materialEditor); if ((SpMode)_SpMode.floatValue == SpMode.Anisotropic) { materialEditor.TexturePropertySingleLine(Styles.anisotropy, _AnisotropyMap, _Anisotropy); materialEditor.TexturePropertySingleLine(Styles.tangent, _TangentMap); } else if ((SpMode)_SpMode.floatValue == SpMode.Fake) { materialEditor.TexturePropertySingleLine(Styles.fakeHighlights, _FakeHightlights); materialEditor.ShaderProperty(_FakeHighlightIntensity, Styles.fakeHighlightIntensity); } TSFunctions.DrawSelector(Enum.GetNames(typeof(IndirectSpecular)), _indirectSpecular, Styles.indirectSpecular, materialEditor); if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Matcap) { materialEditor.TexturePropertySingleLine(Styles.matcap, _Matcap); } else if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Cubemap) { materialEditor.TexturePropertySingleLine(Styles.cubemap, _Cubemap); } else if ((IndirectSpecular)_indirectSpecular.floatValue == IndirectSpecular.Color) { TSFunctions.ProperColorBox(ref _IndirectColor, Styles.indirectColor); } if ((IndirectSpecular)_indirectSpecular.floatValue != IndirectSpecular.None) { TSFunctions.ProperToggle(ref _IndirectOverride, Styles.indirectOverride); } else { _IndirectOverride.floatValue = 0; } isToonyHighlightsEnabled = TSFunctions.ProperToggle(ref _ToonyHighlights, Styles.toonyHighlight); if (isToonyHighlightsEnabled) { EditorGUILayout.BeginHorizontal(); materialEditor.TexturePropertySingleLine(Styles.highlightRamp, _HighlightRamp, _HighlightRampColor); if (GUILayout.Button(Styles.GradientEditorButton)) { EditorGUILayout.EndHorizontal(); isGradientEditorOpen = !isGradientEditorOpen; Styles.ToggleGradientEditorToggle(isGradientEditorOpen); } else { EditorGUILayout.EndHorizontal(); } if (isGradientEditorOpen) { EditorGUILayout.BeginVertical("box"); if (needToStorePreviousRamp) { needToStorePreviousRamp = false; gradientEditor.TranslateTextureToGradient((Texture2D)_HighlightRamp.textureValue); PreviousRamp = _HighlightRamp.textureValue; } if (_HighlightRamp.textureValue != (Texture)gradientEditor.GetGradientTexture()) { _HighlightRamp.textureValue = (Texture)gradientEditor.GetGradientTexture(); } if (gradientEditor.DrawGUI()) { materialEditor.Repaint(); } if (GUILayout.Button("Save and apply")) { string path = inspector.GetTextureDestinationPath((Material)_HighlightRamp.targets[0], "_highlight_ramp.png"); _HighlightRamp.textureValue = (Texture)gradientEditor.SaveGradient(path); needToStorePreviousRamp = true; PreviousRamp = null; isGradientEditorOpen = false; } EditorGUILayout.EndVertical(); } else { if (PreviousRamp != null) { _HighlightRamp.textureValue = PreviousRamp; PreviousRamp = null; needToStorePreviousRamp = true; } } materialEditor.ShaderProperty(_HighlightRampOffset, Styles.hightlightRampOffset); materialEditor.ShaderProperty(_HighlightIntensity, Styles.highlightIntensity); } materialEditor.TexturePropertySingleLine(Styles.highlightPattern, _HighlightPattern); EditorGUI.indentLevel++; materialEditor.TextureScaleOffsetProperty(_HighlightPattern); EditorGUI.indentLevel--; EditorGUILayout.Space(); }
public override void SectionContent(MaterialEditor materialEditor, MaterialProperty[] properties) { FindProperties(properties); bool isOcclusionOffsetEnabled; EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); materialEditor.TexturePropertySingleLine(Styles.ramp, _Ramp, _RampColor); if (GUILayout.Button(Styles.GradientEditorButton)) { EditorGUILayout.EndHorizontal(); isGradientEditorOpen = !isGradientEditorOpen; Styles.ToggleGradientEditorToggle(isGradientEditorOpen); } else { EditorGUILayout.EndHorizontal(); } if (isGradientEditorOpen) { EditorGUILayout.BeginVertical("box"); if (needToStorePreviousRamp) { needToStorePreviousRamp = false; gradientEditor.TranslateTextureToGradient((Texture2D)_Ramp.textureValue); PreviousRamp = _Ramp.textureValue; } if (_Ramp.textureValue != (Texture)gradientEditor.GetGradientTexture()) { _Ramp.textureValue = (Texture)gradientEditor.GetGradientTexture(); } if (gradientEditor.DrawGUI()) { materialEditor.Repaint(); } if (GUILayout.Button("Save and apply")) { string path = inspector.GetTextureDestinationPath((Material)_Ramp.targets[0], "_ramp.png"); _Ramp.textureValue = (Texture)gradientEditor.SaveGradient(path); needToStorePreviousRamp = true; PreviousRamp = null; isGradientEditorOpen = false; } EditorGUILayout.EndVertical(); } else { if (PreviousRamp != null) { _Ramp.textureValue = PreviousRamp; PreviousRamp = null; needToStorePreviousRamp = true; } } if (EditorGUI.EndChangeCheck()) { inspector.GenerateRampMinMax(properties); } EditorGUILayout.Space(); materialEditor.ShaderProperty(_RampOffset, Styles.rampOffset); EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(_ShadowIntensity, Styles.shadowIntensity); if (EditorGUI.EndChangeCheck()) { inspector.GenerateRampMinMax(properties); } isOcclusionOffsetEnabled = TSFunctions.ProperToggle(ref _OcclusionOffset, Styles.occlusionOffsetIntensity); if (!isOcclusionOffsetEnabled && !_OcclusionOffset.hasMixedValue) { _OcclusionOffsetIntensity.floatValue = 0; } if (isOcclusionOffsetEnabled) { materialEditor.ShaderProperty(_OcclusionOffsetIntensity, Styles.occlusionOffsetIntensity); } EditorGUILayout.Space(); }