Wired shapes shown when i change outline size of textmeshpro from script

i built i custom editor that allows me to change many gameobject text settings like changing the font color and adding outline and more

when i set the stroke size = 0 , everything works fun with every font i try but when i change the stoke size only default unity font works other fonts shows a weird shapes like this :


i tried changing the stroke(outline) individually from inspector and its works well so maybe i miss something on the script
this is the script

public void UpdateSettings()
{
    for(int x=0;x<transform.childCount ;x++)
        {
            GameObject country = transform.GetChild(x).gameObject;
            country.GetComponent<SpriteRenderer>().color = countriesColor;
            country.transform.GetChild(0).gameObject.SetActive(showNames);
            if(showNames)
            {
            TextMeshProUGUI text = country.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
            Material mat = text.fontSharedMaterial;
            if(fontAsset != null)
            {
            text.font = fontAsset;
            }
            if(strokeSize == 0)
            {
              
            }
            else
            {
                mat.shaderKeywords = new string[]{"OUTLINE_ON"};
            }
            text.color = fontColor;
            text.fontStyle = fontStyle;
            text.outlineWidth = strokeSize;
            text.outlineColor = strokeColor;
            text.text = country.name;
            }
        }
      
}

note : i am using unity 2019.4

This doesn’t relate to any 2D feature. I’ll move your post to the Scripting forum.

Please note, you can post code using code-tags , you don’t need to paste screenshots which make it very hard for someone to refer to the code. They cannot copy/paste, refer to a line number etc.

Also note, you can edit your posts. :slight_smile:

sorry i was hurry i updated the thread

i fixed the problem by unpacking the prefab completely i don’t know why but its worked