/// <summary>
        /// Load the GlobalFontData FontData (if it exists) and subscribe to the
        /// EditorApplication.hierarchyChanged Event.
        /// </summary>
        public static void Init()
        {
            globalFontName = EditorPrefs.GetString(GlobalFontUtils.GLOBAL_FONT_KEY, GlobalFontUtils.ARIAL);

            // Load GlobalFontData
            GlobalFontData = GlobalFontUtils.LoadGlobalFont(globalFontName);

            if (GlobalFontData == null)
            {
                //Debug.LogWarning(
                //    "<color=red>Global FontData not found! Please select one from Fonts/Select Global Font window!</color>."
                //    );

                return;
            }
            else if (GlobalFontData.font == null)
            {
                Debug.LogWarning(
                    "<color=red>Global Font not found! Please select one from Fonts/Select Global Font window!.</color>"
                    );

                return;
            }

            if (GlobalFontData.name == GlobalFontUtils.ARIAL)
            {
                StopListening();
                return;
            }

            StartListening();
        }
Esempio n. 2
0
 /// <summary>
 /// Checks if a FontData assets is created, else it creates one.
 /// </summary>
 /// <param name="selectedFont"></param>
 private void SetGlobalFontData(Font selectedFont)
 {
     if (!File.Exists(string.Format("{0}{1}{2}.asset", Application.dataPath, GlobalFontUtils.SAVE_PATH, selectedFont.name)))
     {
         GlobalFontUtils.SaveGlobalFont(selectedFont);
         GlobalFontManager.Init();
     }
     else
     {
         if (!GlobalFontManager.IsInit)
         {
             EditorPrefs.SetString(GlobalFontUtils.GLOBAL_FONT_KEY, selectedFont.name);
             GlobalFontManager.Init();
         }
         else
         {
             GlobalFontManager.GlobalFontData = GlobalFontUtils.LoadGlobalFont(selectedFont.name);
         }
     }
 }