static void PasteMaterialProperties(MenuCommand command) { if (m_copiedProperties == null) { Debug.LogWarning("No Material Properties to Paste. Use Copy Material Properties first."); return; } Material mat = (Material)command.context; Undo.RecordObject(mat, "Paste Material"); 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); }
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); }
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); }