Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

There is something wrong with this method (TMP_MaterialManager.ClearMaterials())

Discussion in 'UGUI & TextMesh Pro' started by zyonghao, Oct 21, 2020.

  1. zyonghao

    zyonghao

    Joined:
    Aug 2, 2019
    Posts:
    5
    Code (CSharp):
    1.         public static void ClearMaterials()
    2.         {
    3.             if (m_materialList.Count == 0)
    4.             {
    5.                 Debug.Log("Material List has already been cleared.");
    6.                 return;
    7.             }
    8.  
    9.             for (int i = 0; i < m_materialList.Count; i++)
    10.             {
    11.                 //Material baseMaterial = m_materialList[i].baseMaterial;
    12.                 Material stencilMaterial = m_materialList[i].stencilMaterial;
    13.  
    14.                 Object.DestroyImmediate(stencilMaterial);
    15.                 m_materialList.RemoveAt(i);
    16.             }
    17.         }
    It should be:
    Code (CSharp):
    1.         public static void ClearMaterials()
    2.         {
    3.             if (m_materialList.Count == 0)
    4.             {
    5.                 Debug.Log("Material List has already been cleared.");
    6.                 return;
    7.             }
    8.  
    9.             for (int i = 0; i < m_materialList.Count; i++)
    10.             {
    11.                 //Material baseMaterial = m_materialList[i].baseMaterial;
    12.                 Material stencilMaterial = m_materialList[i].stencilMaterial;
    13.  
    14.                 Object.DestroyImmediate(stencilMaterial);
    15.                 //m_materialList.RemoveAt(i);
    16.             }
    17.             m_materialList.Clear();
    18.         }
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This function should no longer be referenced / used in the latest release of the TMP package.

    Having said that, I concur with your change and have revised this function as such (even if it is no longer reference by the code in the TMP package).