상세 컨텐츠

본문 제목

[Solution ]Unity TextMeshProNUI Property how to Enable via Script

개발생활/Unity Engine

by 한국인맛집 2020. 5. 11. 16:28

본문

반응형
public GameObject textObject;
// Componets Object

public void EnableProperty(){
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_Glow);
    // Glow Property
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_MASK_HARD);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_MASK_SOFT);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_Bevel);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_MASK_TEX);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_Ratios);
    
    textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.EnableKeyword(ShaderUtilities.Keyword_Underlay);
    // UnderLay Property
             
}

public void DisabledProperty(){
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_Glow);
    // Glow Property
    textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_MASK_HARD);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_MASK_SOFT);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_Bevel);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_MASK_TEX);
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_Ratios);
    
	textObject.GetComponent<TextMeshProUGUI>().fontSharedMaterial.DisableKeyword(ShaderUtilities.Keyword_Underlay);
    // UnderLay Property
}

 

TextMeshProUGUI에서 폰트 메터리얼의 KeyWord를 컨트롤 해주면 된다.

 

반응형

관련글 더보기