Version: 2023.2

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 '-'"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961