static void ResetSettings(MenuCommand command) { Material mat = null; if (command.context.GetType() == typeof(Material)) { mat = (Material)command.context; } else { mat = Selection.activeGameObject.GetComponent <CanvasRenderer>().GetMaterial(); } Undo.RecordObject(mat, "Reset Material"); ShaderUtilities.GetShaderPropertyIDs(); // Make sure we have valid Property IDs if (mat.HasProperty(ShaderUtilities.ID_GradientScale)) { // Copy unique properties of the SDF Material var texture = mat.GetTexture(ShaderUtilities.ID_MainTex); var gradientScale = mat.GetFloat(ShaderUtilities.ID_GradientScale); var texWidth = mat.GetFloat(ShaderUtilities.ID_TextureWidth); var texHeight = mat.GetFloat(ShaderUtilities.ID_TextureHeight); var stencilId = mat.GetFloat(ShaderUtilities.ID_StencilID); var stencilComp = mat.GetFloat(ShaderUtilities.ID_StencilComp); var normalWeight = mat.GetFloat(ShaderUtilities.ID_WeightNormal); var boldWeight = mat.GetFloat(ShaderUtilities.ID_WeightBold); // Reset the material Unsupported.SmartReset(mat); // Reset ShaderKeywords mat.shaderKeywords = new string[0]; // { "BEVEL_OFF", "GLOW_OFF", "UNDERLAY_OFF" }; // Copy unique material properties back to the material. mat.SetTexture(ShaderUtilities.ID_MainTex, texture); mat.SetFloat(ShaderUtilities.ID_GradientScale, gradientScale); mat.SetFloat(ShaderUtilities.ID_TextureWidth, texWidth); mat.SetFloat(ShaderUtilities.ID_TextureHeight, texHeight); mat.SetFloat(ShaderUtilities.ID_StencilID, stencilId); mat.SetFloat(ShaderUtilities.ID_StencilComp, stencilComp); mat.SetFloat(ShaderUtilities.ID_WeightNormal, normalWeight); mat.SetFloat(ShaderUtilities.ID_WeightBold, boldWeight); } else { Unsupported.SmartReset(mat); } TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, mat); }
// Special Handling of Undo / Redo Events. private void OnUndoRedo() { //Debug.Log("Undo / Redo Event ID (" + Undo.GetCurrentGroup() + ") occured."); int UndoEventID = Undo.GetCurrentGroup(); int LastUndoEventID = m_eventID; if (UndoEventID != LastUndoEventID) { //Debug.Log("Undo Redo Event processed by Material Editor. Affected Material is " + target + " with ID " + target.GetInstanceID()); // Event ID:" + UndoEventID + ". Target ID: " + m_modifiedProperties.target.GetInstanceID() + " Current Material: " + m_modifiedProperties.objectReference + " New Material: " + (m_modifiedProperties.target as Renderer).sharedMaterial); TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, target as Material); //TMPro_EventManager.ON_BASE_MATERIAL_CHANGED(target as Material); m_eventID = UndoEventID; } }
void PrepareGUI() { isNewGUI = false; TMP_UIStyleManager.GetUIStyles(); ShaderUtilities.GetShaderPropertyIDs(); // New GUI just got constructed. This happens in response to a selection, // but also after undo/redo events. if (lastSeenUndoRedoCount != undoRedoCount) { // There's been at least one undo/redo since the last time this GUI got constructed. // Maybe the undo/redo was for this material? Assume that is was. TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, material as Material); } lastSeenUndoRedoCount = undoRedoCount; }
static void ResetSettings(MenuCommand command) { Material mat = null; if (command.context.GetType() == typeof(Material)) { mat = (Material)command.context; } else { #if UNITY_4_6 || UNITY_5 mat = Selection.activeGameObject.GetComponent <CanvasRenderer>().GetMaterial(); #endif } //Material mat = (Material)command.context; Undo.RecordObject(mat, "Reset Material"); Material tmp_mat = new Material(mat.shader); ShaderUtilities.GetShaderPropertyIDs(); // Make sure we have valid Property IDs if (mat.HasProperty(ShaderUtilities.ID_GradientScale)) { // Copy unique properties of the SDF Material over to the temp material. tmp_mat.SetTexture(ShaderUtilities.ID_MainTex, mat.GetTexture(ShaderUtilities.ID_MainTex)); tmp_mat.SetFloat(ShaderUtilities.ID_GradientScale, mat.GetFloat(ShaderUtilities.ID_GradientScale)); tmp_mat.SetFloat(ShaderUtilities.ID_TextureWidth, mat.GetFloat(ShaderUtilities.ID_TextureWidth)); tmp_mat.SetFloat(ShaderUtilities.ID_TextureHeight, mat.GetFloat(ShaderUtilities.ID_TextureHeight)); tmp_mat.SetFloat(ShaderUtilities.ID_StencilID, mat.GetFloat(ShaderUtilities.ID_StencilID)); tmp_mat.SetFloat(ShaderUtilities.ID_StencilComp, mat.GetFloat(ShaderUtilities.ID_StencilComp)); mat.CopyPropertiesFromMaterial(tmp_mat); // Reset ShaderKeywords mat.shaderKeywords = new string[0]; // { "BEVEL_OFF", "GLOW_OFF", "UNDERLAY_OFF" }; } else { mat.CopyPropertiesFromMaterial(tmp_mat); } DestroyImmediate(tmp_mat); TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, mat); }
private UndoPropertyModification[] OnUndoRedoEvent(UndoPropertyModification[] modifications) { PropertyModification modifiedProperties = modifications[0].propertyModification; System.Type objType = modifiedProperties.target.GetType(); if (objType == typeof(MeshRenderer) || objType == typeof(Material)) // && UndoEventID != LastUndoEventID) { //Debug.Log("OnUndoRedoEvent() received in Material Editor. Event ID:" + UndoEventID + ". Target ID: " + m_modifiedProperties.target.GetInstanceID() + " Current Material: " + m_modifiedProperties.objectReference + " New Material: " + (m_modifiedProperties.target as Renderer).sharedMaterial); TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, target as Material); } if (target != null) { EditorUtility.SetDirty(target); } return(modifications); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { editor = materialEditor; material = (materialEditor.target as Material); this.properties = properties; if (isNewGUI) { PrepareGUI(); } EditorGUIUtility.labelWidth = 130f; EditorGUIUtility.fieldWidth = 50f; DoDragAndDropBegin(); EditorGUI.BeginChangeCheck(); DoGUI(); if (EditorGUI.EndChangeCheck()) { TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, material); } DoDragAndDropEnd(); }
static void PasteMaterialProperties(MenuCommand command) { if (m_copiedProperties == null) { Debug.LogWarning("No Material Properties to Paste. Use Copy Material Properties first."); return; } Material mat = null; if (command.context.GetType() == typeof(Material)) { mat = (Material)command.context; } else { #if UNITY_4_6 || UNITY_5 mat = Selection.activeGameObject.GetComponent <CanvasRenderer>().GetMaterial(); #endif } Undo.RecordObject(mat, "Paste Material"); ShaderUtilities.GetShaderPropertyIDs(); // Make sure we have valid Property IDs if (mat.HasProperty(ShaderUtilities.ID_GradientScale)) { // Preserve unique SDF properties from destination material. m_copiedProperties.SetTexture(ShaderUtilities.ID_MainTex, mat.GetTexture(ShaderUtilities.ID_MainTex)); m_copiedProperties.SetFloat(ShaderUtilities.ID_GradientScale, mat.GetFloat(ShaderUtilities.ID_GradientScale)); m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureWidth, mat.GetFloat(ShaderUtilities.ID_TextureWidth)); m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureHeight, mat.GetFloat(ShaderUtilities.ID_TextureHeight)); } EditorShaderUtilities.CopyMaterialProperties(m_copiedProperties, mat); // Copy ShaderKeywords from one material to the other. mat.shaderKeywords = m_copiedProperties.shaderKeywords; // Let TextMeshPro Objects that this mat has changed. TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, mat); }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { m_Editor = materialEditor; m_Material = materialEditor.target as Material; this.m_Properties = properties; if (m_IsNewGUI) { PrepareGUI(); } DoDragAndDropBegin(); EditorGUI.BeginChangeCheck(); DoGUI(); if (EditorGUI.EndChangeCheck()) { TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material); } DoDragAndDropEnd(); }
private static void PasteMaterialProperties(MenuCommand command) { if (m_copiedProperties == null) { Debug.LogWarning("No Material Properties to Paste. Use Copy Material Properties first."); return; } Material material = null; material = ((command.context.GetType() != typeof(Material)) ? Selection.activeGameObject.GetComponent <CanvasRenderer>().GetMaterial() : ((Material)command.context)); Undo.RecordObject(material, "Paste Material"); ShaderUtilities.GetShaderPropertyIDs(); if (material.HasProperty(ShaderUtilities.ID_GradientScale)) { m_copiedProperties.SetTexture(ShaderUtilities.ID_MainTex, material.GetTexture(ShaderUtilities.ID_MainTex)); m_copiedProperties.SetFloat(ShaderUtilities.ID_GradientScale, material.GetFloat(ShaderUtilities.ID_GradientScale)); m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureWidth, material.GetFloat(ShaderUtilities.ID_TextureWidth)); m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureHeight, material.GetFloat(ShaderUtilities.ID_TextureHeight)); } EditorShaderUtilities.CopyMaterialProperties(m_copiedProperties, material); material.shaderKeywords = m_copiedProperties.shaderKeywords; TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, material); }
public override void OnInspectorGUI() { // if we are not visible... return //if (!isVisible) // return; ReadMaterialProperties(); Material targetMaterial = target as Material; // If multiple materials have been selected and are not using the same shader, we simply return. if (targets.Length > 1) { for (int i = 0; i < targets.Length; i++) { Material mat = targets[i] as Material; if (targetMaterial.shader != mat.shader) { return; } } } // Retrieve Shader Multi_Compile Keywords m_Keywords = targetMaterial.shaderKeywords; isBevelEnabled = m_Keywords.Contains("BEVEL_ON"); isGlowEnabled = m_Keywords.Contains("GLOW_ON"); //isUnderlayEnabled = m_Keywords.Contains("UNDERLAY_ON") | m_Keywords.Contains("UNDERLAY_INNER"); isRatiosEnabled = !m_Keywords.Contains("RATIOS_OFF"); if (m_Keywords.Contains("UNDERLAY_ON")) { isUnderlayEnabled = true; m_underlaySelection = Underlay_Types.Normal; } else if (m_Keywords.Contains("UNDERLAY_INNER")) { isUnderlayEnabled = true; m_underlaySelection = Underlay_Types.Inner; } else { isUnderlayEnabled = false; } if (m_Keywords.Contains("MASK_HARD")) { m_mask = Mask_Type.MaskHard; } else if (m_Keywords.Contains("MASK_SOFT")) { m_mask = Mask_Type.MaskSoft; } else { m_mask = Mask_Type.MaskOff; } if (m_shaderFlags.hasMixedValue) { m_bevelSelection = 2; } else { m_bevelSelection = (int)m_shaderFlags.floatValue & 1; } // Define the Drag-n-Drop Region (Start) m_inspectorStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); // Check if Shader selection is compatible with Font Asset // TODO EditorGUIUtility.LookLikeControls(130, 50); // FACE PANEL EditorGUI.indentLevel = 0; if (GUILayout.Button("<b>Face</b> - <i>Settings</i> -", Group_Label)) { m_foldout.face = !m_foldout.face; } if (m_foldout.face) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_faceColor, "Color"); if (targetMaterial.HasProperty("_FaceTex")) { DrawTextureProperty(m_faceTex, "Texture"); DrawUVProperty(new MaterialProperty[] { m_faceUVSpeedX, m_faceUVSpeedY }, "UV Speed"); } DrawSliderProperty(m_outlineSoftness, "Softness"); DrawSliderProperty(m_faceDilate, "Dilate"); if (targetMaterial.HasProperty("_FaceShininess")) { DrawSliderProperty(m_faceShininess, "Gloss"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } // OUTLINE PANEL EditorGUI.indentLevel = 0; if (GUILayout.Button("<b>Outline</b> - <i>Settings</i> -", Group_Label)) { m_foldout.outline = !m_foldout.outline; } if (m_foldout.outline) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_outlineColor, "Color"); if (targetMaterial.HasProperty("_OutlineTex")) { DrawTextureProperty(m_outlineTex, "Texture"); DrawUVProperty(new MaterialProperty[] { m_outlineUVSpeedX, m_outlineUVSpeedY }, "UV Speed"); } DrawSliderProperty(m_outlineThickness, "Thickness"); if (targetMaterial.HasProperty("_OutlineShininess")) { DrawSliderProperty(m_outlineShininess, "Gloss"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } // UNDERLAY PANEL if (targetMaterial.HasProperty("_UnderlayColor")) { string underlayKeyword = m_underlaySelection == Underlay_Types.Normal ? "UNDERLAY_ON" : "UNDERLAY_INNER"; isUnderlayEnabled = DrawTogglePanel(FoldoutType.underlay, "<b>Underlay</b> - <i>Settings</i> -", isUnderlayEnabled, underlayKeyword); if (m_foldout.underlay) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; m_underlaySelection = (Underlay_Types)EditorGUILayout.EnumPopup("Underlay Type", m_underlaySelection); if (GUI.changed) { SetUnderlayKeywords(); } ColorProperty(m_underlayColor, "Color"); DrawSliderProperty(m_underlayOffsetX, "OffsetX"); DrawSliderProperty(m_underlayOffsetY, "OffsetY"); DrawSliderProperty(m_underlayDilate, "Dilate"); DrawSliderProperty(m_underlaySoftness, "Softness"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // BEVEL PANEL if (targetMaterial.HasProperty("_Bevel")) { isBevelEnabled = DrawTogglePanel(FoldoutType.bevel, "<b>Bevel</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.bevel) { EditorGUI.indentLevel = 1; GUI.changed = false; m_bevelSelection = EditorGUILayout.Popup("Type", m_bevelSelection, m_bevelOptions) & 1; if (GUI.changed) { havePropertiesChanged = true; m_shaderFlags.floatValue = m_bevelSelection; } EditorGUI.BeginChangeCheck(); DrawSliderProperty(m_bevel, "Amount"); DrawSliderProperty(m_bevelOffset, "Offset"); DrawSliderProperty(m_bevelWidth, "Width"); DrawSliderProperty(m_bevelRoundness, "Roundness"); DrawSliderProperty(m_bevelClamp, "Clamp"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // LIGHTING PANEL if (targetMaterial.HasProperty("_SpecularColor") || targetMaterial.HasProperty("_SpecColor")) { isBevelEnabled = DrawTogglePanel(FoldoutType.light, "<b>Lighting</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.light) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; if (targetMaterial.HasProperty("_LightAngle")) { // Non Surface Shader DrawSliderProperty(m_lightAngle, "Light Angle"); ColorProperty(m_specularColor, "Specular Color"); DrawSliderProperty(m_specularPower, "Specular Power"); DrawSliderProperty(m_reflectivity, "Reflectivity Power"); DrawSliderProperty(m_diffuse, "Diffuse Shadow"); DrawSliderProperty(m_ambientLight, "Ambient Shadow"); } else { ColorProperty(m_specColor, "Specular Color"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // BUMPMAP PANEL if (targetMaterial.HasProperty("_BumpMap")) { isBevelEnabled = DrawTogglePanel(FoldoutType.bump, "<b>BumpMap</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.bump) { EditorGUI.BeginChangeCheck(); DrawTextureProperty(m_bumpMap, "Texture"); DrawSliderProperty(m_bumpFace, "Face"); DrawSliderProperty(m_bumpOutline, "Outline"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // ENVMAP PANEL if (targetMaterial.HasProperty("_Cube")) { isBevelEnabled = DrawTogglePanel(FoldoutType.env, "<b>EnvMap</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.env) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_reflectFaceColor, "Face Color"); ColorProperty(m_reflectOutlineColor, "Outline Color"); DrawTextureProperty(m_reflectTex, "Texture"); if (targetMaterial.HasProperty("_Cube")) { DrawVectorProperty(m_reflectRotation, "EnvMap Rotation"); //var matrix = targetMaterial.GetMatrix("_EnvMatrix"); } if (EditorGUI.EndChangeCheck()) { //var m = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(m_matrixRotation), new Vector3(1f, 1f, 1f)); //targetMaterial.SetMatrix("_EnvMatrix", m); havePropertiesChanged = true; } } } // GLOW PANEL if (targetMaterial.HasProperty("_GlowColor")) { isGlowEnabled = DrawTogglePanel(FoldoutType.glow, "<b>Glow</b> - <i>Settings</i> -", isGlowEnabled, "GLOW_ON"); if (m_foldout.glow) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_glowColor, "Color"); DrawSliderProperty(m_glowOffset, "Offset"); DrawSliderProperty(m_glowInner, "Inner"); DrawSliderProperty(m_glowOuter, "Outer"); DrawSliderProperty(m_glowPower, "Power"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // DEBUG PANEL if (targetMaterial.HasProperty("_GradientScale")) { EditorGUI.indentLevel = 0; if (GUILayout.Button("<b>Debug</b> - <i>Settings</i> -", Group_Label)) { m_foldout.debug = !m_foldout.debug; } if (m_foldout.debug) { EditorGUI.indentLevel = 1; EditorGUI.BeginChangeCheck(); DrawTextureProperty(m_mainTex, "Font Atlas"); DrawFloatProperty(m_gradientScale, "Gradient Scale"); DrawFloatProperty(m_texSampleWidth, "Texture Width"); DrawFloatProperty(m_texSampleHeight, "Texture Height"); GUILayout.Space(20); DrawSliderProperty(m_scaleX, "Scale X"); DrawSliderProperty(m_scaleY, "Scale Y"); DrawSliderProperty(m_PerspectiveFilter, "Perspective Filter"); GUILayout.Space(20); DrawFloatProperty(m_vertexOffsetX, "Offset X"); DrawFloatProperty(m_vertexOffsetY, "Offset Y"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } // Mask if (targetMaterial.HasProperty("_MaskCoord")) { GUILayout.Space(15); m_mask = (Mask_Type)EditorGUILayout.EnumPopup("Mask", m_mask); if (GUI.changed) { havePropertiesChanged = true; SetMaskKeywords(m_mask); } if (m_mask != Mask_Type.MaskOff) { EditorGUI.BeginChangeCheck(); Draw2DBoundsProperty(m_maskCoord, "Mask Bounds"); DrawFloatProperty(m_maskSoftnessX, "Softness X"); DrawFloatProperty(m_maskSoftnessY, "Softness Y"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } GUILayout.Space(15); } GUILayout.Space(20); // Stencil if (targetMaterial.HasProperty("_Stencil")) { FloatProperty(m_stencilID, "Stencil ID"); FloatProperty(m_stencilComp, "Stencil Comp"); FloatProperty(m_stencilOp, "Stencil Op"); } GUILayout.Space(20); // Ratios GUI.changed = false; isRatiosEnabled = EditorGUILayout.Toggle("Enable Ratios?", isRatiosEnabled); if (GUI.changed) { SetKeyword(!isRatiosEnabled, "RATIOS_OFF"); } EditorGUI.BeginChangeCheck(); DrawFloatProperty(m_scaleRatio_A, "Scale Ratio A"); DrawFloatProperty(m_scaleRatio_B, "Scale Ratio B"); DrawFloatProperty(m_scaleRatio_C, "Scale Ratio C"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } // Define the Drag-n-Drop Region (End) m_inspectorEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); DragAndDropGUI(); if (havePropertiesChanged) { //Debug.Log("Material Editor properties have changed. Target is " + target.name); havePropertiesChanged = false; PropertiesChanged(); EditorUtility.SetDirty(target); //TMPro_EditorUtility.RepaintAll(); // Look into using SetDirty. TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, target as Material); } }
public override void OnInspectorGUI() { if (!m_foldout.editorPanel) { return; } Material material = base.target as Material; if (base.targets.Length > 1) { for (int i = 0; i < base.targets.Length; i++) { Material material2 = base.targets[i] as Material; if (material.shader != material2.shader) { return; } } } ReadMaterialProperties(); if (!material.HasProperty(ShaderUtilities.ID_GradientScale)) { m_warning = WarningTypes.ShaderMismatch; m_warningMsg = "The selected Shader is not compatible with the currently selected Font Asset type."; EditorGUILayout.HelpBox(m_warningMsg, MessageType.Warning); return; } m_Keywords = material.shaderKeywords; isOutlineEnabled = m_Keywords.Contains("OUTLINE_ON"); isBevelEnabled = m_Keywords.Contains("BEVEL_ON"); isGlowEnabled = m_Keywords.Contains("GLOW_ON"); isRatiosEnabled = !m_Keywords.Contains("RATIOS_OFF"); if (m_Keywords.Contains("UNDERLAY_ON")) { isUnderlayEnabled = true; m_underlaySelection = Underlay_Types.Normal; } else if (m_Keywords.Contains("UNDERLAY_INNER")) { isUnderlayEnabled = true; m_underlaySelection = Underlay_Types.Inner; } else { isUnderlayEnabled = false; } if (m_Keywords.Contains("MASK_HARD")) { m_mask = MaskingTypes.MaskHard; } else if (m_Keywords.Contains("MASK_SOFT")) { m_mask = MaskingTypes.MaskSoft; } else { m_mask = MaskingTypes.MaskOff; } if (m_shaderFlags.hasMixedValue) { m_bevelSelection = 2; } else { m_bevelSelection = ((int)m_shaderFlags.floatValue & 1); } m_inspectorStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); EditorGUIUtility.labelWidth = 130f; EditorGUIUtility.fieldWidth = 50f; EditorGUI.indentLevel = 0; if (GUILayout.Button("<b>Face</b> - <i>Settings</i> -", TMP_UIStyleManager.Group_Label)) { m_foldout.face = !m_foldout.face; } if (m_foldout.face) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_faceColor, "Color"); if (material.HasProperty("_FaceTex")) { DrawTextureProperty(m_faceTex, "Texture"); DrawUVProperty(new MaterialProperty[2] { m_faceUVSpeedX, m_faceUVSpeedY }, "UV Speed"); } DrawRangeProperty(m_outlineSoftness, "Softness"); DrawRangeProperty(m_faceDilate, "Dilate"); if (material.HasProperty("_FaceShininess")) { DrawRangeProperty(m_faceShininess, "Gloss"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } if (material.HasProperty("_OutlineColor")) { if (material.HasProperty("_Bevel")) { if (GUILayout.Button("<b>Outline</b> - <i>Settings</i> -", TMP_UIStyleManager.Group_Label)) { m_foldout.outline = !m_foldout.outline; } } else { isOutlineEnabled = DrawTogglePanel(FoldoutType.outline, "<b>Outline</b> - <i>Settings</i> -", isOutlineEnabled, "OUTLINE_ON"); } EditorGUI.indentLevel = 0; if (m_foldout.outline) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_outlineColor, "Color"); if (material.HasProperty("_OutlineTex")) { DrawTextureProperty(m_outlineTex, "Texture"); DrawUVProperty(new MaterialProperty[2] { m_outlineUVSpeedX, m_outlineUVSpeedY }, "UV Speed"); } DrawRangeProperty(m_outlineThickness, "Thickness"); if (material.HasProperty("_OutlineShininess")) { DrawRangeProperty(m_outlineShininess, "Gloss"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_UnderlayColor")) { string keyword = (m_underlaySelection == Underlay_Types.Normal) ? "UNDERLAY_ON" : "UNDERLAY_INNER"; isUnderlayEnabled = DrawTogglePanel(FoldoutType.underlay, "<b>Underlay</b> - <i>Settings</i> -", isUnderlayEnabled, keyword); if (m_foldout.underlay) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; m_underlaySelection = (Underlay_Types)(object)EditorGUILayout.EnumPopup("Underlay Type", m_underlaySelection); if (GUI.changed) { SetUnderlayKeywords(); } ColorProperty(m_underlayColor, "Color"); DrawRangeProperty(m_underlayOffsetX, "OffsetX"); DrawRangeProperty(m_underlayOffsetY, "OffsetY"); DrawRangeProperty(m_underlayDilate, "Dilate"); DrawRangeProperty(m_underlaySoftness, "Softness"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_Bevel")) { isBevelEnabled = DrawTogglePanel(FoldoutType.bevel, "<b>Bevel</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.bevel) { EditorGUI.indentLevel = 1; GUI.changed = false; m_bevelSelection = (EditorGUILayout.Popup("Type", m_bevelSelection, m_bevelOptions) & 1); if (GUI.changed) { havePropertiesChanged = true; m_shaderFlags.floatValue = m_bevelSelection; } EditorGUI.BeginChangeCheck(); DrawRangeProperty(m_bevel, "Amount"); DrawRangeProperty(m_bevelOffset, "Offset"); DrawRangeProperty(m_bevelWidth, "Width"); DrawRangeProperty(m_bevelRoundness, "Roundness"); DrawRangeProperty(m_bevelClamp, "Clamp"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_SpecularColor") || material.HasProperty("_SpecColor")) { isBevelEnabled = DrawTogglePanel(FoldoutType.light, "<b>Lighting</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.light) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; if (material.HasProperty("_LightAngle")) { DrawRangeProperty(m_lightAngle, "Light Angle"); ColorProperty(m_specularColor, "Specular Color"); DrawRangeProperty(m_specularPower, "Specular Power"); DrawRangeProperty(m_reflectivity, "Reflectivity Power"); DrawRangeProperty(m_diffuse, "Diffuse Shadow"); DrawRangeProperty(m_ambientLight, "Ambient Shadow"); } else { ColorProperty(m_specColor, "Specular Color"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_BumpMap")) { isBevelEnabled = DrawTogglePanel(FoldoutType.bump, "<b>BumpMap</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.bump) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; DrawTextureProperty(m_bumpMap, "Texture"); DrawRangeProperty(m_bumpFace, "Face"); DrawRangeProperty(m_bumpOutline, "Outline"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_Cube")) { isBevelEnabled = DrawTogglePanel(FoldoutType.env, "<b>EnvMap</b> - <i>Settings</i> -", isBevelEnabled, "BEVEL_ON"); if (m_foldout.env) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_reflectFaceColor, "Face Color"); ColorProperty(m_reflectOutlineColor, "Outline Color"); DrawTextureProperty(m_reflectTex, "Texture"); if (material.HasProperty("_Cube")) { DrawVectorProperty(m_reflectRotation, "EnvMap Rotation"); } if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_GlowColor")) { isGlowEnabled = DrawTogglePanel(FoldoutType.glow, "<b>Glow</b> - <i>Settings</i> -", isGlowEnabled, "GLOW_ON"); if (m_foldout.glow) { EditorGUI.BeginChangeCheck(); EditorGUI.indentLevel = 1; ColorProperty(m_glowColor, "Color"); DrawRangeProperty(m_glowOffset, "Offset"); DrawRangeProperty(m_glowInner, "Inner"); DrawRangeProperty(m_glowOuter, "Outer"); DrawRangeProperty(m_glowPower, "Power"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } if (material.HasProperty("_GradientScale")) { EditorGUI.indentLevel = 0; if (GUILayout.Button("<b>Debug</b> - <i>Settings</i> -", TMP_UIStyleManager.Group_Label)) { m_foldout.debug = !m_foldout.debug; } if (m_foldout.debug) { EditorGUI.indentLevel = 1; EditorGUI.BeginChangeCheck(); DrawTextureProperty(m_mainTex, "Font Atlas"); DrawFloatProperty(m_gradientScale, "Gradient Scale"); DrawFloatProperty(m_texSampleWidth, "Texture Width"); DrawFloatProperty(m_texSampleHeight, "Texture Height"); GUILayout.Space(20f); DrawFloatProperty(m_scaleX, "Scale X"); DrawFloatProperty(m_scaleY, "Scale Y"); DrawRangeProperty(m_PerspectiveFilter, "Perspective Filter"); GUILayout.Space(20f); DrawFloatProperty(m_vertexOffsetX, "Offset X"); DrawFloatProperty(m_vertexOffsetY, "Offset Y"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } if (material.HasProperty("_ClipRect")) { GUILayout.Space(15f); m_mask = (MaskingTypes)(object)EditorGUILayout.EnumPopup("Mask", m_mask); if (GUI.changed) { havePropertiesChanged = true; SetMaskKeywords(m_mask); } if (m_mask != 0) { EditorGUI.BeginChangeCheck(); Draw2DBoundsProperty(m_maskCoord, "Mask Bounds"); DrawFloatProperty(m_maskSoftnessX, "Softness X"); DrawFloatProperty(m_maskSoftnessY, "Softness Y"); if (material.HasProperty("_MaskEdgeColor")) { DrawTextureProperty(m_maskTex, "Mask Texture"); bool value = (m_maskTexInverse.floatValue != 0f) ? true : false; value = EditorGUILayout.Toggle("Inverse Mask", value); ColorProperty(m_maskTexEdgeColor, "Edge Color"); RangeProperty(m_maskTexEdgeSoftness, "Edge Softness"); RangeProperty(m_maskTexWipeControl, "Wipe Position"); if (EditorGUI.EndChangeCheck()) { m_maskTexInverse.floatValue = (value ? 1 : 0); havePropertiesChanged = true; } } } GUILayout.Space(15f); } EditorGUI.BeginChangeCheck(); Draw2DRectBoundsProperty(m_clipRect, "_ClipRect"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } GUILayout.Space(20f); if (material.HasProperty("_Stencil")) { FloatProperty(m_stencilID, "Stencil ID"); FloatProperty(m_stencilComp, "Stencil Comp"); } GUILayout.Space(20f); GUI.changed = false; isRatiosEnabled = EditorGUILayout.Toggle("Enable Ratios?", isRatiosEnabled); if (GUI.changed) { SetKeyword(!isRatiosEnabled, "RATIOS_OFF"); } EditorGUI.BeginChangeCheck(); DrawFloatProperty(m_scaleRatio_A, "Scale Ratio A"); DrawFloatProperty(m_scaleRatio_B, "Scale Ratio B"); DrawFloatProperty(m_scaleRatio_C, "Scale Ratio C"); if (EditorGUI.EndChangeCheck()) { havePropertiesChanged = true; } } } m_inspectorEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); DragAndDropGUI(); if (havePropertiesChanged) { havePropertiesChanged = false; PropertiesChanged(); EditorUtility.SetDirty(base.target); TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, base.target as Material); } }