using UnityEngine;
using System.Collections;
///
/// 字体管理者,向外部提供字体
///
public class FontManager : MonoBehaviour
{
///
/// 单键
///
private static FontManager pInit = null;
///
/// UI字体
///
[SerializeField]
private Font uiFont = null;
///
/// 获取字体管理者
///
/// 单键实例
public static FontManager Instance()
{
return pInit;
}
///
/// 初始化
///
private void Awake()
{
pInit = this;
Init();
// 切换关卡时不删除
DontDestroyOnLoad(this);
}
///
/// 获取当前字体
///
public Font CurFont
{
get
{
return uiFont;
}
}
private string chineseText = null;
public void Init()
{
if (chineseText == null)
{
var wordFileRes = Resources.Load("Font/chineseWords");
if (wordFileRes != null)
{
TextAsset worldFile = wordFileRes as TextAsset;
chineseText = worldFile.text;
chineseText = worldFile.text;
Debug.Log(string.Format("chinese font size: {0}", chineseText.Length));
}
}
////uiFont = Resources.Load("Font/AMCSL", typeof(Font)) as Font;
////uiFont.material = Resources.Load("Font/AMCSL", typeof(Material)) as Material;
////if (uiFont != null)
////{
//// uiFont.RequestCharactersInTexture(chineseText);
//// Texture texture = uiFont.material.mainTexture;
//// Debug.Log(string.Format("Texture size: {0}, {1}", texture.width, texture.height));
////}
}
}