/// <summary> /// Static constructor. Created when Unity first loads. /// </summary> static EntryPoint() { // Retrieve the saved name of the current global text asset var textAssetName = EditorPrefs.GetString(StringLibrary.GLOBAL_FONT_KEY, StringLibrary.ARIAL); // Load the saved global text asset var globalTextAsset = AssetProcessor.LoadTextAsset(textAssetName); // If, for some reason, there is no text asset, create a default Arial text asset if (globalTextAsset == null) { AssetProcessor.CreateDefaultTextAsset(); globalTextAsset = AssetProcessor.LoadTextAsset(textAssetName); } // Create the listener for notifications of newly create Text objects var hierarchyListener = new HierarchyListener(); // Grab all, if any, Text objects in the scene var allTextObjects = Resources.FindObjectsOfTypeAll(typeof(Text)); if (allTextObjects == null) { allTextObjects = Resources.FindObjectsOfTypeAll(typeof(Text)); } // Create and initialize the GlobalFontSettings new GlobalTextSettings(globalTextAsset, allTextObjects); // Initialize the listener for the font settings window GlobalTextSettingsWindow.hierarchyListener = hierarchyListener; // Start listening for the creation of text objects hierarchyListener.Listen(); }
/// <summary> /// Reset to Unity's standard font, "Arial". /// </summary> private void ResetFontButton() { EditorGUILayout.Space(); if (GUILayout.Button("Reset Font")) { var selctedFont = StringLibrary.ARIAL; AssetProcessor.CreateDefaultTextAsset(); GlobalTextSettings.TextSettings = AssetProcessor.LoadTextAsset(selctedFont); hierarchyListener.Listen(); fontDisplayName = selctedFont; RepaintAll(); } }