Font.HasCharacter 特定字符

function HasCharacter (c : char) : bool

Does this font have a specific character?

这个字体是否有特定字符?

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	private TextMesh t;
	void Start() {
		t = transform.GetComponent<TextMesh>();
		if (t.font.HasCharacter("-"[0]))
			Debug.Log("Font supports '-' sign.");
		else
			Debug.LogWarning("This font doesnt support '-'");
	}
}
// Detects if the current font of a 3D text supports '-' sign
//检测如果一个3D文字支持当前的字体' - '符号
private var t : TextMesh;
function Start() {
	t = transform.GetComponent(TextMesh);
	if (t.font.HasCharacter("-"[0])) {
		Debug.Log("Font supports '-' sign.");
	} else {
		Debug.LogWarning("This font doesnt support '-'");
	}
}
Page last updated: 2010-12-9