Esempio n. 1
0
        // Event received when custom material editor properties are changed.
        void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
        {
            //Debug.Log("*** ON_MATERIAL_PROPERTY_CHANGED ***");
            int targetMaterialID         = mat.GetInstanceID();
            int sharedMaterialID         = m_sharedMaterial.GetInstanceID();
            int fallbackSourceMaterialID = m_fallbackSourceMaterial == null ? 0 : m_fallbackSourceMaterial.GetInstanceID();

            // Filter events and return if the affected material is not this object's material.
            if (targetMaterialID != sharedMaterialID)
            {
                // Check if event applies to the source fallback material
                if (m_fallbackMaterial != null && fallbackSourceMaterialID == targetMaterialID)
                {
                    TMP_MaterialManager.CopyMaterialPresetProperties(mat, m_fallbackMaterial);
                }
                else
                {
                    return;
                }
            }

            if (m_TextComponent == null)
            {
                m_TextComponent = GetComponentInParent <TextMeshPro>();
            }

            m_padding = GetPaddingForMaterial();

            m_TextComponent.havePropertiesChanged = true;
            m_TextComponent.SetVerticesDirty();
        }
        // Event received when custom material editor properties are changed.
        void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
        {
            //Debug.Log("*** ON_MATERIAL_PROPERTY_CHANGED ***");
            if (m_sharedMaterial == null)
            {
                return;
            }

            int targetMaterialID         = mat.GetInstanceID();
            int sharedMaterialID         = m_sharedMaterial.GetInstanceID();
            int fallbackSourceMaterialID = m_fallbackSourceMaterial == null ? 0 : m_fallbackSourceMaterial.GetInstanceID();

            // Sync culling with parent text object
            bool  hasCullModeProperty = m_sharedMaterial.HasProperty(ShaderUtilities.ShaderTag_CullMode);
            float cullMode            = 0;

            if (hasCullModeProperty)
            {
                cullMode = textComponent.fontSharedMaterial.GetFloat(ShaderUtilities.ShaderTag_CullMode);
                m_sharedMaterial.SetFloat(ShaderUtilities.ShaderTag_CullMode, cullMode);
            }

            // Filter events and return if the affected material is not this object's material.
            if (targetMaterialID != sharedMaterialID)
            {
                // Check if event applies to the source fallback material
                if (m_fallbackMaterial != null && fallbackSourceMaterialID == targetMaterialID && TMP_Settings.matchMaterialPreset)
                {
                    TMP_MaterialManager.CopyMaterialPresetProperties(mat, m_fallbackMaterial);

                    // Re-sync culling with parent text object
                    if (hasCullModeProperty)
                    {
                        m_fallbackMaterial.SetFloat(ShaderUtilities.ShaderTag_CullMode, cullMode);
                    }
                }
                else
                {
                    return;
                }
            }

            m_padding = GetPaddingForMaterial();

            m_TextComponent.havePropertiesChanged = true;
            m_TextComponent.SetVerticesDirty();
        }
Esempio n. 3
0
 public void SetVerticesDirty()
 {
     if (base.enabled && m_TextComponent != null)
     {
         m_TextComponent.havePropertiesChanged = true;
         m_TextComponent.SetVerticesDirty();
     }
 }
Esempio n. 4
0
        // Event received when custom material editor properties are changed.
        void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
        {
            //Debug.Log("*** ON_MATERIAL_PROPERTY_CHANGED ***");

            // Filter events and return if the affected material is not this object's material.
            if (mat.GetInstanceID() != m_sharedMaterial.GetInstanceID())
            {
                return;
            }

            if (m_TextComponent == null)
            {
                m_TextComponent = GetComponentInParent <TextMeshPro>();
            }

            m_padding = GetPaddingForMaterial();

            m_TextComponent.havePropertiesChanged = true;
            m_TextComponent.SetVerticesDirty();
        }
Esempio n. 5
0
 private void OnContainerChanged()
 {
     UpdateCorners();
     if (m_rectTransform != null)
     {
         m_rectTransform.sizeDelta  = size;
         m_rectTransform.hasChanged = true;
     }
     if (textMeshPro != null)
     {
         m_textMeshPro.SetVerticesDirty();
         m_textMeshPro.margin = m_margins;
     }
 }
 static int SetVerticesDirty(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         TMPro.TextMeshPro obj = (TMPro.TextMeshPro)ToLua.CheckObject <TMPro.TextMeshPro>(L, 1);
         obj.SetVerticesDirty();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }