12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// 字体管理者,向外部提供字体
- /// </summary>
- public class FontManager : MonoBehaviour
- {
- /// <summary>
- /// 单键
- /// </summary>
- private static FontManager pInit = null;
- /// <summary>
- /// UI字体
- /// </summary>
- [SerializeField]
- private Font uiFont = null;
- /// <summary>
- /// 获取字体管理者
- /// </summary>
- /// <returns>单键实例</returns>
- public static FontManager Instance()
- {
- return pInit;
- }
- /// <summary>
- /// 初始化
- /// </summary>
- private void Awake()
- {
- pInit = this;
- Init();
- // 切换关卡时不删除
- DontDestroyOnLoad(this);
- }
- /// <summary>
- /// 获取当前字体
- /// </summary>
- 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));
- ////}
- }
- }
|