Font.HasCharacter

切换到手册
public bool HasCharacter (char c);

参数

c要检查的字符。

返回

bool 该字体是否已指定了此字符。

描述

该字体是否有指定字符?

此函数检查该字体是否定义了特定字符。某些字体没有定义所有字符(例如,无符号,或者无小写字符)。

using UnityEngine;

public class FontCheck : MonoBehaviour { // Detects if the current font of a 3D text // supports '-' sign TextMesh t; void Start() { t = transform.GetComponent<TextMesh>(); if (t.font.HasCharacter('-')) { Debug.Log("Font supports '-' sign."); } else { Debug.LogWarning("This font doesnt support '-'"); } } }