コード例 #1
0
ファイル: TMPro_FontEditor.cs プロジェクト: gww2/EvilTiles
        public void OnEnable()
        {
            font_atlas_prop = serializedObject.FindProperty("atlas");
            font_material_prop = serializedObject.FindProperty("material");

            font_normalStyle_prop = serializedObject.FindProperty("normalStyle");
            font_normalSpacing_prop = serializedObject.FindProperty("normalSpacingOffset");

            font_boldStyle_prop = serializedObject.FindProperty("boldStyle");
            font_boldSpacing_prop = serializedObject.FindProperty("boldSpacing");

            font_italicStyle_prop = serializedObject.FindProperty("italicStyle");
            font_tabSize_prop = serializedObject.FindProperty("tabSize");

            m_fontInfo_prop = serializedObject.FindProperty("m_fontInfo");
            m_glyphInfoList_prop = serializedObject.FindProperty("m_glyphInfoList");
            m_kerningInfo_prop = serializedObject.FindProperty("m_kerningInfo");
            m_kerningPair_prop = serializedObject.FindProperty("m_kerningPair");

            //m_isGlyphInfoListExpanded_prop = serializedObject.FindProperty("isGlyphInfoListExpanded");
            //m_isKerningTableExpanded_prop = serializedObject.FindProperty("isKerningTableExpanded");

            m_fontAsset = target as TMP_FontAsset;
            m_kerningTable = m_fontAsset.kerningInfo;

            // Get the UI Skin and Styles for the various Editors
            TMP_UIStyleManager.GetUIStyles();
        }
コード例 #2
0
        // Function used to find the Font Asset which matches the given Material Preset and Font Atlas Texture.
        public static TMP_FontAsset FindMatchingFontAsset(Material mat)
        {
            if (mat.GetTexture(ShaderUtilities.ID_MainTex) == null)
            {
                return(null);
            }

            // Find the dependent assets of this material.
            string[] dependentAssets = AssetDatabase.GetDependencies(AssetDatabase.GetAssetPath(mat), false);

            for (int i = 0; i < dependentAssets.Length; i++)
            {
                TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath <TMP_FontAsset>(dependentAssets[i]);
                if (fontAsset != null)
                {
                    return(fontAsset);
                }
            }

            return(null);
        }
コード例 #3
0
        // Sets up all the languages
        internal static void Setup()
        {
            // Constructs new fonts for the game
            newFont      = TMP_FontAsset.CreateFontAsset(Packs.Global.Get <Font>("CustomFont"));
            newFont.name = "CustomFont";

            newFontHebrew      = TMP_FontAsset.CreateFontAsset(Packs.Global.Get <Font>("CustomFontHebrew"));
            newFontHebrew.name = "CustomFontHebrew";

            newFontArmenian      = TMP_FontAsset.CreateFontAsset(Packs.Global.Get <Font>("CustomFontArmenian"));
            newFontArmenian.name = "CustomFontArmenian";

            // Creates language fallback for language symbols

            // Marks languages as RTL to adjust them then loading
            LanguageController.AddRTLSupport(Enums.Langs.HE);

            // Corrects the language display on the language selection
            LangTranslations(null);
            LanguageController.TranslationReset += LangTranslations;
        }
コード例 #4
0
ファイル: Am_Text.cs プロジェクト: ShenKSPZ/Amtion
 public Am_Text(string DisplayText,
                TMP_FontAsset Font = null,
                int Size           = 24,
                bool Bold          = false, bool Italic = false, bool Underline = false, bool Strike = false, bool Highlight = false, bool LowerCase = false, bool UpperCase = false, bool Subscript = false, bool Superscript = false,
                Color color        = default, VertexGradient gradient = default)
 {
     this.DisplayText = DisplayText;
     this.Font        = Font;
     this.Size        = Size;
     this.Bold        = Bold;
     this.Italic      = Italic;
     this.Underline   = Underline;
     this.Strike      = Strike;
     this.Highlight   = Highlight;
     this.LowerCase   = LowerCase;
     this.UpperCase   = UpperCase;
     this.Subscript   = Subscript;
     this.Superscript = Superscript;
     this.color       = color;
     this.gradient    = gradient;
 }
コード例 #5
0
    //TODO second pass
    public FloatingText(Vector3 anchorPoint, Transform parent, TMP_FontAsset font, int fontSize, TextAlignmentOptions alignment)
    {
        velocity   = new Vector3(0f, 0.01f, 0f);
        spawnPoint = anchorPoint;

        GameObject cashObject = new GameObject("FloatingText", typeof(TextMeshProUGUI), typeof(Canvas));

        cashObject.GetComponent <Canvas>().sortingOrder = 10;

        cashObject.transform.SetParent(parent);

        cashText = cashObject.GetComponent <TextMeshProUGUI>();
        cashText.rectTransform.localScale = new Vector3(0.02f, 0.02f, 0.02f);
        cashText.alignment = alignment;
        cashText.enabled   = true;
        cashText.transform.localPosition = spawnPoint;
        cashText.font     = font;
        cashText.fontSize = fontSize;

        AdjustPositionToAlignment(alignment);
    }
コード例 #6
0
ファイル: CM_DialogBox.cs プロジェクト: udoheld/ChroMapper
 public void SetParams(string message, Action <int> result,
                       string button0Text         = null, string button1Text = null, string button2Text = null,
                       TMP_FontAsset button0Asset = null, TMP_FontAsset button1Asset = null, TMP_FontAsset button2Asset = null)
 {
     if (IsEnabled)
     {
         throw new Exception("Dialog box is already enabled! Please wait until this Dialog Box has been disabled.");
     }
     UpdateGroup(true);
     UIMessage.text = message;
     resultAction   = result;
     UIButtons[0].gameObject.SetActive(button0Text != null);
     UIButtons[1].gameObject.SetActive(button1Text != null);
     UIButtons[2].gameObject.SetActive(button2Text != null);
     UIButtons[0].GetComponentInChildren <TextMeshProUGUI>().text = button0Text ?? "";
     UIButtons[1].GetComponentInChildren <TextMeshProUGUI>().text = button1Text ?? "";
     UIButtons[2].GetComponentInChildren <TextMeshProUGUI>().text = button2Text ?? "";
     UIButtons[0].GetComponentInChildren <TextMeshProUGUI>().font = button0Asset ?? defaultFont;
     UIButtons[1].GetComponentInChildren <TextMeshProUGUI>().font = button1Asset ?? defaultFont;
     UIButtons[2].GetComponentInChildren <TextMeshProUGUI>().font = button2Asset ?? defaultFont;
 }
コード例 #7
0
        public TMP_FontAsset CopyFontAsset(TMP_FontAsset original, Material referenceMaterial, string newName = null)
        {
            TMP_FontAsset copy = Object.Instantiate(original);

            // Unity doesn't copy textures when using Object.Instantiate so we have to do it manually
            Texture2D texture    = original.atlasTexture;
            Texture2D newTexture = new Texture2D(texture.width, texture.height, texture.format, texture.mipmapCount, true);

            Graphics.CopyTexture(texture, newTexture);

            Material material = new Material(referenceMaterial);

            material.SetTexture("_MainTex", newTexture);

            kAtlasTextureAccessor(ref copy) = newTexture;
            copy.name          = !string.IsNullOrWhiteSpace(newName) ? newName : original.name;
            copy.atlasTextures = new[] { newTexture };
            copy.material      = material;

            return(copy);
        }
コード例 #8
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            foreach (var asset in importedAssets)
            {
                // Return if imported asset path is outside of the project.
                if (asset.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase) == false)
                {
                    continue;
                }

                if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(TMP_FontAsset))
                {
                    TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath(asset, typeof(TMP_FontAsset)) as TMP_FontAsset;

                    if (fontAsset != null)
                    {
                        TMP_EditorResourceManager.RegisterFontAssetForDefinitionRefresh(fontAsset);
                    }
                }
            }
        }
コード例 #9
0
    public GameObject CreateTextBoxes(string text)
    {
        TMP_FontAsset font = Resources.Load("Kievit-Medium") as TMP_FontAsset;
        GameObject    txt  = new GameObject("answer");
        RectTransform rect = txt.AddComponent <RectTransform>();

        //rect.sizeDelta = new Vector2(width / 2, height / 4-60);
        rect.transform.position = new Vector3(0, 25, 0);
        rect.anchorMin          = new Vector2(0.5f, 0.5f);
        rect.anchorMax          = new Vector2(0.5f, 0.5f);
        rect.pivot = new Vector2(0.5f, 0.5f);
        txt.AddComponent <CanvasRenderer>();
        TextMeshProUGUI tmp = txt.AddComponent <TextMeshProUGUI>();

        tmp.text          = text;
        tmp.font          = font;
        tmp.alignment     = TextAlignmentOptions.Center;
        tmp.raycastTarget = false;

        return(txt);
    }
コード例 #10
0
        public void OnEnable()
        {
            font_atlas_prop    = serializedObject.FindProperty("atlas");
            font_material_prop = serializedObject.FindProperty("material");

            fontWeights_prop = serializedObject.FindProperty("fontWeights");

            //fontWeight_Thin = serializedObject.FindProperty("thin");
            //fontWeight_ExtraLight = serializedObject.FindProperty("extraLight");
            //fontWeight_Light = serializedObject.FindProperty("light");
            //fontWeight_Normal = serializedObject.FindProperty("normal");
            //fontWeight_Medium = serializedObject.FindProperty("medium");
            //fontWeight_DemiBold = serializedObject.FindProperty("demiBold");
            //fontWeight_Bold = serializedObject.FindProperty("bold");
            //fontWeight_Heavy = serializedObject.FindProperty("heavy");
            //fontWeight_Black = serializedObject.FindProperty("black");

            font_normalStyle_prop   = serializedObject.FindProperty("normalStyle");
            font_normalSpacing_prop = serializedObject.FindProperty("normalSpacingOffset");

            font_boldStyle_prop   = serializedObject.FindProperty("boldStyle");
            font_boldSpacing_prop = serializedObject.FindProperty("boldSpacing");

            font_italicStyle_prop = serializedObject.FindProperty("italicStyle");
            font_tabSize_prop     = serializedObject.FindProperty("tabSize");

            m_fontInfo_prop      = serializedObject.FindProperty("m_fontInfo");
            m_glyphInfoList_prop = serializedObject.FindProperty("m_glyphInfoList");
            m_kerningInfo_prop   = serializedObject.FindProperty("m_kerningInfo");
            m_kerningPair_prop   = serializedObject.FindProperty("m_kerningPair");

            //m_isGlyphInfoListExpanded_prop = serializedObject.FindProperty("isGlyphInfoListExpanded");
            //m_isKerningTableExpanded_prop = serializedObject.FindProperty("isKerningTableExpanded");

            m_fontAsset    = target as TMP_FontAsset;
            m_kerningTable = m_fontAsset.kerningInfo;

            // Get the UI Skin and Styles for the various Editors
            TMP_UIStyleManager.GetUIStyles();
        }
コード例 #11
0
ファイル: AtavismObjectText.cs プロジェクト: clock2255/awagas
        //    bool upadteIsRunning = false;
        //   Coroutine chTimer;
        // Use this for initialization
        void Start()
        {
            //   node = GetComponent<AtavismNode>();
            obj       = new GameObject("obj");
            obj.layer = LayerMask.NameToLayer(AtavismCursor.Instance.layerForTexts);
            obj.transform.SetParent(transform, false);
            objectText       = new GameObject("ObjectText");
            objectText.layer = LayerMask.NameToLayer(AtavismCursor.Instance.layerForTexts);
            objectText.transform.SetParent(obj.transform, false);

            obj.transform.localPosition        = new Vector3(0f, height, 0f);
            objectText.transform.localPosition = textPosition;
            TextMeshPro textMeshPro = objectText.AddComponent <TextMeshPro>();

            textMeshPro.alignment = TextAlignmentOptions.Midline;
            textMeshPro.margin    = textMargin;
            textMeshPro.fontSize  = 2;

            textMeshPro.color = textColour;
            TMP_FontAsset font1 = Resources.Load("Lato-BoldSDFNames", typeof(TMP_FontAsset)) as TMP_FontAsset;

            textMeshPro.font         = font1;
            textMeshPro.outlineWidth = 0.2f;

#if AT_I2LOC_PRESET
            if (!string.IsNullOrEmpty(I2.Loc.LocalizationManager.GetTranslation(textfield)))
            {
                objectText.GetComponent <TextMeshPro>().text = I2.Loc.LocalizationManager.GetTranslation(textfield);
            }
#else
            textMeshPro.text = textfield;
#endif

            AtavismEventSystem.RegisterEvent("UPDATE_LANGUAGE", this);
            if (!AtavismSettings.Instance.NameVisable)
            {
                textMeshPro.enabled = false;
            }
            StartCoroutine(UpdateTimer());
        }
コード例 #12
0
ファイル: PUITuning.cs プロジェクト: peterhaneve/ONIMods
            static Fonts()
            {
                FONTS = new Dictionary <string, TMP_FontAsset>(16);
                // List out all fonts shipped with the game
                foreach (var newFont in Resources.FindObjectsOfTypeAll <TMP_FontAsset>())
                {
                    string name = newFont?.name;
                    if (!string.IsNullOrEmpty(name) && !FONTS.ContainsKey(name))
                    {
                        FONTS.Add(name, newFont);
                    }
                }

                // Initialization: UI fonts
                if ((DefaultTextFont = GetFontByName(DEFAULT_FONT_TEXT)) == null)
                {
                    PUIUtils.LogUIWarning("Unable to find font " + DEFAULT_FONT_TEXT);
                }
                if ((DefaultUIFont = GetFontByName(DEFAULT_FONT_UI)) == null)
                {
                    PUIUtils.LogUIWarning("Unable to find font " + DEFAULT_FONT_UI);
                }

                // Initialization: Text style
                DefaultSize   = 14;
                TextDarkStyle = ScriptableObject.CreateInstance <TextStyleSetting>();
                TextDarkStyle.enableWordWrapping = false;
                TextDarkStyle.fontSize           = DefaultSize;
                TextDarkStyle.sdfFont            = Text;
                TextDarkStyle.style            = FontStyles.Normal;
                TextDarkStyle.textColor        = Colors.UITextDark;
                TextLightStyle                 = TextDarkStyle.DeriveStyle(newColor: Colors.UITextLight);
                UIDarkStyle                    = ScriptableObject.CreateInstance <TextStyleSetting>();
                UIDarkStyle.enableWordWrapping = false;
                UIDarkStyle.fontSize           = DefaultSize;
                UIDarkStyle.sdfFont            = UI;
                UIDarkStyle.style              = FontStyles.Normal;
                UIDarkStyle.textColor          = Colors.UITextDark;
                UILightStyle                   = UIDarkStyle.DeriveStyle(newColor: Colors.UITextLight);
            }
コード例 #13
0
        private void ChangeFontLanguage(FontLanguage fontLanguage)
        {
            //IL_0037: Unknown result type (might be due to invalid IL or missing references)
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a9: Unknown result type (might be due to invalid IL or missing references)
            if (!((Dictionary <FontLanguage, FontData>)m_data).TryGetValue(fontLanguage, out FontData value))
            {
                Log.Error($"Font collection named '{this.get_name()}' doesn't have any font data for font language '{fontLanguage}'.", 444, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\UI\\FontCollection.cs");
                return;
            }
            AssetReference fontAssetReference = value.fontAssetReference;

            if (!fontAssetReference.get_hasValue())
            {
                Log.Error($"Font collection named '{this.get_name()}' doesn't have a font setup for font language '{fontLanguage}'.", 451, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\UI\\FontCollection.cs");
                return;
            }
            TMP_FontAsset val = fontAssetReference.LoadFromResources <TMP_FontAsset>();

            if (null == val)
            {
                Log.Error($"Font collection named '{this.get_name()}' failed to load font for font language '{fontLanguage}'.", 458, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\UI\\FontCollection.cs");
                return;
            }
            AssetReference styleMaterialReference = value.styleMaterialReference;
            Material       styleMaterial          = styleMaterialReference.get_hasValue() ? styleMaterialReference.LoadFromResources <Material>() : null;

            if (null != m_styleMaterial)
            {
                Resources.UnloadAsset(m_styleMaterial);
            }
            if (null != m_fontAsset)
            {
                Resources.UnloadAsset(m_fontAsset);
            }
            m_fontData      = value;
            m_fontAsset     = val;
            m_styleMaterial = styleMaterial;
        }
コード例 #14
0
        void UpdateFont(TMP_FontAsset fontFile)
        {
            var fontText = m_SourceFontFile.text;
            var fnt      = FntParse.GetFntParse(ref fontText);

            for (int i = 0; i < fontFile.characterTable.Count; i++)
            {
                var unicode    = fontFile.characterTable[i].unicode;
                var glyphIndex = fontFile.characterTable[i].glyphIndex;
                for (int j = 0; j < fnt.charInfos.Length; j++)
                {
                    if (unicode == fnt.charInfos[j].index)
                    {
                        var glyph = fontFile.glyphLookupTable[glyphIndex];
                        PatchGlyph(fnt.rawCharInfos[j],
                                   fnt.textureHeight,
                                   fnt.textureWidth,
                                   ref glyph);
                        fontFile.glyphLookupTable[glyphIndex] = glyph;
                        break;
                    }
                }
            }

            var newFaceInfo = fontFile.faceInfo;

            newFaceInfo.baseline   = fnt.lineBaseHeight;
            newFaceInfo.lineHeight = fnt.lineHeight;
            newFaceInfo.ascentLine = fnt.lineHeight;
            newFaceInfo.pointSize  = fnt.fontSize;

            var fontType         = typeof(TMP_FontAsset);
            var faceInfoProperty = fontType.GetProperty("faceInfo");

            faceInfoProperty.SetValue(fontFile, newFaceInfo);

            fontFile.material.SetTexture("_MainTex", m_Texture2D);
            fontFile.atlasTextures[0] = m_Texture2D;
        }
コード例 #15
0
        IEnumerator LoadFontCoroutine()
        {
            yield return(new WaitForSecondsRealtime(5f));

            if (File.Exists(Configuration.PluginConfig.Instance.font))
            {
                try
                {
                    Font          font      = FontManager.AddFontFile(Configuration.PluginConfig.Instance.font);
                    TMP_FontAsset fontAsset = BeatSaberUI.CreateTMPFont(font);
                    uiFont = BeatSaberUI.CreateFixedUIFontClone(fontAsset);
                    if (uiFont != null)
                    {
                        uiFontEnabled = true;
                    }
                }
                catch
                {
                    Logger.log.Error($"Failed to load font: {Configuration.PluginConfig.Instance.font}");
                }
            }
        }
コード例 #16
0
        private void ReplaceTMPFont(TMP_FontAsset font)
        {
            string[] dir    = new string[] { searchDir };
            string[] assets = AssetDatabase.FindAssets("", dir);

            bool isSave = false;

            for (int i = 0; i < assets.Length; i++)
            {
                //AssetのGUIDパスを取得
                string guid     = assets [i];
                string guidPath = AssetDatabase.GUIDToAssetPath(guid);
                //プログレスバーを表示
                EditorUtility.DisplayProgressBar(title, guidPath, (float)i / (float)assets.Length);

                GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(guidPath);
                if (go != null)
                {
                    //TMPProの配列を取得
                    TextMeshProUGUI[] textList = go.GetComponentsInChildren <TextMeshProUGUI>(true);
                    for (int j = 0; j < textList.Length; j++)
                    {
                        TextMeshProUGUI text = textList[j];
                        if (text != null)
                        {
                            //fontを入れ替え
                            text.font = font;
                            EditorUtility.SetDirty(text);
                        }
                    }
                    isSave = true;
                }
            }
            if (isSave)
            {
                AssetDatabase.SaveAssets();
            }
            EditorUtility.ClearProgressBar();
        }
コード例 #17
0
        public static List <TextMeshPro> CreateTextMeshList(string word, TMP_FontAsset font, float fontSize)
        {
            List <TextMeshPro> texts    = new List <TextMeshPro>();
            Vector3            position = new Vector3(0, 0, 0);
            var totalWidth = 0f;
            var height     = 0f;

            foreach (var ch in word)
            {
                if (texts.Count > 0)
                {
                    position += new Vector3(texts.Last().preferredWidth / 1.8f, 0f, 0f);
                }
                var textMesh = CreateTextMesh(ch.ToString(), font, fontSize);
                textMesh.name     = "text: " + ch;
                textMesh.fontSize = fontSize;
                textMesh.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
                position += new Vector3(textMesh.preferredWidth / 1.8f, 0f, 0f);
                textMesh.transform.localPosition = position;
                var renderer = textMesh.GetComponent <MeshRenderer>();
                renderer.shadowCastingMode         = ShadowCastingMode.Off;
                renderer.allowOcclusionWhenDynamic = false;
                totalWidth += textMesh.preferredWidth;
                if (height < textMesh.preferredHeight)
                {
                    height = textMesh.preferredHeight;
                }
                texts.Add(textMesh);
            }

            var diff = new Vector3(totalWidth / 2f, -height, 0f);

            foreach (var t in texts)
            {
                t.transform.localPosition -= diff;
            }

            return(texts);
        }
コード例 #18
0
        public void AssignFont(TextMeshProUGUI tmp, TMP_FontAsset baseFont, Material baseMaterial)
        {
            int fontIndex     = -1;
            int materialIndex = -1;

            for (int i = 0; i < _baseFontGroup.fontMaterialGroups.Length; i++)
            {
                if (_baseFontGroup.fontMaterialGroups[i].textMeshProFont == baseFont)
                {
                    fontIndex = i;

                    for (int j = 0; j < _baseFontGroup.fontMaterialGroups[i].textMeshProMaterials.Length; j++)
                    {
                        if (_baseFontGroup.fontMaterialGroups[i].textMeshProMaterials[j] == baseMaterial)
                        {
                            materialIndex = j;
                            break;
                        }
                    }

                    break;
                }
            }

            if (fontIndex >= 0 && materialIndex >= 0)
            {
                for (int i = 0; i < _fontGroups.Length; i++)
                {
                    if (_fontGroups[i].language == Texto.currentLanguage)
                    {
                        tmp.font = _fontGroups[i].fontMaterialGroups[fontIndex].textMeshProFont;
                        tmp.fontSharedMaterial = _fontGroups[i].fontMaterialGroups[fontIndex].textMeshProMaterials[materialIndex];
                        tmp.lineSpacing        = _fontGroups[i].lineHeight;
                        tmp.fontStyle          = new FontStyles();
                        break;
                    }
                }
            }
        }
コード例 #19
0
        public static void Reset()
        {
            // Reinitialize state to known values
            Employer       = null;
            EmployerRep    = SimGameReputation.INDIFFERENT;
            EmployerRepRaw = 0;
            IsEmployerAlly = false;
            MRBRating      = 0;

            Compensation = 0;

            PotentialSalvage.Clear();
            HeldbackParts.Clear();
            CompensationParts.Clear();

            Contract          = null;
            SimGameState      = null;
            AAR_SalvageScreen = null;
            SGCurrencyDisplay = null;
            HBSPopupRoot      = null;
            FloatieFont       = null;
        }
コード例 #20
0
ファイル: TextUtils.cs プロジェクト: mralve/DotsUI
        public static void SetupFontAssetFromTmp(EntityManager mgr, Entity entity, TMP_FontAsset font)
        {
            mgr.SetSharedComponentData(entity, new LegacyTextFontAsset
            {
                Asset        = font,
                FontMaterial = font.material
            });

            mgr.SetComponentData(entity, new TextFontAsset
            {
                LineHeight  = font.faceInfo.lineHeight,
                AscentLine  = font.faceInfo.ascentLine,
                Baseline    = font.faceInfo.baseline,
                BoldSpace   = font.boldSpacing,
                CapLine     = font.faceInfo.capLine,
                DescentLine = font.faceInfo.descentLine,
                MeanLine    = font.faceInfo.meanLine,
                NormalSpace = font.normalSpacingOffset,
                PointSize   = font.faceInfo.pointSize,
                BoldStyle   = font.boldStyle,
                NormalStyle = font.normalStyle,
                AtlasSize   = new float2(font.atlasWidth, font.atlasHeight),
            });


            var buffer = mgr.GetBuffer <FontGlyphData>(entity);

            buffer.Reserve(font.glyphLookupTable.Count);
            foreach (var glyph in font.characterLookupTable)
            {
                buffer.Add(new FontGlyphData()
                {
                    Character = (ushort)glyph.Key,
                    Scale     = glyph.Value.scale,
                    Rect      = glyph.Value.glyph.glyphRect,
                    Metrics   = glyph.Value.glyph.metrics
                });
            }
        }
コード例 #21
0
        /// <summary>

        /// Method to retrieve the material presets that match the currently selected font asset.

        /// </summary>

        private string[] GetMaterialPresets()

        {
            TMP_FontAsset fontAsset = fontAsset_prop.objectReferenceValue as TMP_FontAsset;

            if (fontAsset == null)
            {
                return(null);
            }



            m_materialPresets = TMP_EditorUtility.FindMaterialReferences(fontAsset);

            m_materialPresetNames = new string[m_materialPresets.Length];



            for (int i = 0; i < m_materialPresetNames.Length; i++)

            {
                m_materialPresetNames[i] = m_materialPresets[i].name;



                if (m_targetMaterial.GetInstanceID() == m_materialPresets[i].GetInstanceID())
                {
                    m_materialPresetSelectionIndex = i;
                }
            }



            m_isPresetListDirty = false;



            return(m_materialPresetNames);
        }
コード例 #22
0
        /// <summary>
        /// Returns true if a <see cref="Font"/> was found for the passed <see cref="FontStyleId"/> or if an
        /// <see cref="OverrideFontAsset"/> was present, otherwise false. If true, <paramref name="fontAsset"/>
        /// will have its value initialized.
        /// </summary>
        /// <param name="fontStyleId"></param>
        /// <param name="fontAsset"></param>
        /// <returns></returns>
        public bool TryGetFont(FontStyleId fontStyleId, out TMP_FontAsset fontAsset)
        {
            fontAsset = null;

            for (var i = 0; i < _fontStyles.Count; i++)
            {
                if (_fontStyles[i].Id != fontStyleId)
                {
                    continue;
                }

                fontAsset = _fontStyles[i].TMPFontAsset;
                break;
            }

            if (fontAsset == null)
            {
                fontAsset = OverrideFontAsset;
            }

            return(fontAsset != null);
        }
コード例 #23
0
ファイル: XLoader.cs プロジェクト: chrislee0419/Enhancements
        public void Initialize()
        {
            if (_fonts.Count > 0)
            {
                return;
            }
            if (!_didLoad)
            {
                // Loading the asset bundle.
                AssetBundle bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(BUNDLE_PATH));

                // Load Fonts
                _cachedTekoFont = Resources.FindObjectsOfTypeAll <TMP_FontAsset>().LastOrDefault(f2 => f2.name == "Teko-Medium SDF");
                var fonts = bundle.LoadAllAssets <TMP_FontAsset>();
                for (int i = 0; i < fonts.Length; i++)
                {
                    var font = Setup(fonts[i]);
                    _fonts.Add(font.name.Split(new string[] { "SDF" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim(' '), font);
                }
                _didLoad = true;
            }
        }
コード例 #24
0
ファイル: FixFont.cs プロジェクト: vutuanhai237/A_Knight
    void OnGUI()
    {
        GUILayout.Label("Fix all font and text in current scene");
        GUILayout.Toggle(true, "Don't change size");
        font = (TMP_FontAsset)EditorGUILayout.ObjectField(font, typeof(TMP_FontAsset), true);
        if (GUILayout.Button("Fix now"))
        {
            if (font != null)
            {
                int counter = 0;
                foreach (TextMeshProUGUI obj in SceneAsset.FindObjectsOfType <TextMeshProUGUI>())
                {
                    if (obj.font != font)
                    {
                        counter++;
                        obj.font = font;
                    }
                }
                //foreach (Text obj in SceneAsset.FindObjectsOfType<Text>())
                //{
                //    try
                //    {
                //        GameObject att = obj.gameObject;
                //        RectTransform oldrt = att.GetComponent<RectTransform>();
                //        RectTransform rt = oldrt.GetCopyOf(new RectTransform());
                //        DestroyImmediate(obj);
                //        DestroyImmediate(att.GetComponent<CanvasRenderer>());
                //        att.AddComponent<TextMeshProUGUI>();
                //        att.GetComponent<TextMeshProUGUI>().font = font;
                //        oldrt = rt.GetCopyOf(new RectTransform());
                //    }
                //    catch { }
                //    counter++;

                //}
                Debug.Log(counter + " item(s) had been fixed!");
            }
        }
    }
コード例 #25
0
            public static void Prefix(HeraldryCreatorPanel __instance, LocalizableText ___screenTitle, LocalizableText ___screenSubTitle, LocalizableText ___mechInfoName)
            {
                try
                {
                    Logger.Debug("[HeraldryCreatorPanel_SetData_PREFIX] Fix position of screen title");

                    TMP_FontAsset ___mechInfoName_m_baseFont = (TMP_FontAsset)AccessTools.Field(typeof(LocalizableText), "m_baseFont").GetValue(___mechInfoName);

                    //___screenTitle.fontSize = 44;
                    ___screenTitle.SetFont(___mechInfoName_m_baseFont);
                    //___screenTitle.text = "Heraldry Customization";

                    // Position title
                    RectTransform screenTitleRT  = ___screenTitle.GetComponent <RectTransform>();
                    Vector3       screenTitlePos = screenTitleRT.localPosition;
                    Logger.Info($"[HeraldryCreatorPanel_SetData_PREFIX] CURRENT position of screen title: {screenTitlePos.x}, {screenTitlePos.y}");

                    screenTitlePos.x = -13;
                    //screenTitlePos.y = -22;
                    screenTitleRT.localPosition = screenTitlePos;
                    Logger.Info($"[HeraldryCreatorPanel_SetData_PREFIX] NEW position of screen title: {screenTitlePos.x}, {screenTitlePos.y}");



                    // Position subtitle
                    RectTransform screenSubTitleRT  = ___screenSubTitle.GetComponent <RectTransform>();
                    Vector3       screenSubTitlePos = screenSubTitleRT.localPosition;
                    Logger.Info($"[HeraldryCreatorPanel_SetData_PREFIX] CURRENT position of screen subtitle: {screenSubTitlePos.x}, {screenSubTitlePos.y}");

                    screenSubTitlePos.x = -12;
                    //screenSubTitlePos.y = -55.8;
                    screenSubTitleRT.localPosition = screenSubTitlePos;
                    Logger.Info($"[HeraldryCreatorPanel_SetData_PREFIX] NEW position of screen subtitle: {screenSubTitlePos.x}, {screenSubTitlePos.y}");
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
コード例 #26
0
ファイル: FontAsset.cs プロジェクト: spicysoft/h5-count-shape
        public override Entity Import(IAssetImporter ctx, TMP_FontAsset font)
        {
            var entity = ctx.CreateEntity(typeof(BitmapFont), typeof(CharacterInfoBuffer));

            ctx.SetComponentData(entity, new BitmapFont()
            {
                textureAtlas = ctx.GetEntity(font.atlasTexture),
                size         = font.creationSettings.pointSize,
                ascent       = font.faceInfo.ascentLine,
                descent      = font.faceInfo.descentLine
            });

            var buffer = ctx.GetBuffer <CharacterInfoBuffer>(entity).Reinterpret <CharacterInfo>();

            foreach (var lookup in font.characterLookupTable)
            {
                var glyph  = lookup.Value;
                var rect   = glyph.glyph.glyphRect;
                var region = new Rect(
                    (float)rect.x / font.atlasTexture.width,
                    (float)rect.y / font.atlasTexture.height,
                    (float)rect.width / font.atlasTexture.width,
                    (float)rect.height / font.atlasTexture.height);

                buffer.Add(new CharacterInfo
                {
                    value           = lookup.Key,
                    advance         = glyph.glyph.metrics.horizontalAdvance,
                    bearingX        = glyph.glyph.metrics.horizontalBearingX,
                    bearingY        = glyph.glyph.metrics.horizontalBearingY,
                    width           = glyph.glyph.metrics.width,
                    height          = glyph.glyph.metrics.height,
                    characterRegion = region
                });
            }

            return(entity);
        }
コード例 #27
0
        void ChangeFont()
        {
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("Panel");
            t = (TMP_FontAsset)EditorGUILayout.ObjectField("prefab", t, typeof(TMP_FontAsset), true);
            if (GUILayout.Button("Find"))
            {
                texts = FindObjectsOfType <TextMeshProUGUI>();
            }

            if (texts != null && texts.Length > 0)
            {
                if (GUILayout.Button("Add"))
                {
                    foreach (TextMeshProUGUI text in texts)
                    {
                        text.font = t;
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
コード例 #28
0
        public static TextMeshPro CreateWorldText(Transform parent, string text = "TEXT")
        {
            GameObject textMeshGO = new GameObject("CustomUIText");

            textMeshGO.SetActive(false);

            TextMeshPro   textMesh = textMeshGO.AddComponent <TextMeshPro>();
            TMP_FontAsset font     = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(x => x.name == "Teko-Medium SDF No Glow"));

            textMesh.renderer.sharedMaterial = font.material;
            textMesh.fontSharedMaterial      = font.material;
            textMesh.font = font;

            textMesh.transform.SetParent(parent, true);
            textMesh.text     = text;
            textMesh.fontSize = 5f;
            textMesh.color    = Color.white;
            textMesh.renderer.material.shader = CustomTextShader;

            textMesh.gameObject.SetActive(true);

            return(textMesh);
        }
コード例 #29
0
        public UnityRenderer(Material uiMat, TMP_FontAsset uiFont,
                             Color linkColor, Color autolinkColor,
                             Sprite quoteBg, Image.Type bgType, Color quoteColor,
                             Sprite codeBg, Image.Type codeBgType, Color codeColor,
                             Sprite inlineCodeBg, Image.Type inlineCodeBgType, Color inlineCodeColor)
        {
            UIMaterial = uiMat;
            UIFont     = uiFont;

            LinkColor     = linkColor;
            AutolinkColor = autolinkColor;

            QuoteBackground     = quoteBg;
            QuoteBackgroundType = bgType;
            QuoteColor          = quoteColor;

            CodeBackground            = codeBg;
            CodeBackgroundType        = codeBgType;
            CodeBackgroundColor       = codeColor;
            InlineCodeBackground      = inlineCodeBg;
            InlineCodeBackgroundType  = inlineCodeBgType;
            InlineCodeBackgroundColor = inlineCodeColor;
        }
コード例 #30
0
ファイル: FontAsset.cs プロジェクト: klanggames/UIForia
        private static IntMap <TextGlyph> ConvertCharacters(TMP_FontAsset asset)
        {
            List <Glyph>       glyphList = asset.glyphTable;
            IntMap <TextGlyph> retn      = new IntMap <TextGlyph>(glyphList.Count);

            for (int i = 0; i < asset.characterTable.Count; i++)
            {
                TextGlyph glyph    = new TextGlyph();
                Glyph     tmpGlyph = asset.characterTable[i].glyph;
                glyph.id       = (int)tmpGlyph.index;
                glyph.height   = tmpGlyph.metrics.height;
                glyph.width    = tmpGlyph.metrics.width;
                glyph.x        = tmpGlyph.glyphRect.x;
                glyph.y        = tmpGlyph.glyphRect.y;
                glyph.scale    = tmpGlyph.scale;
                glyph.xAdvance = tmpGlyph.metrics.horizontalAdvance;
                glyph.xOffset  = tmpGlyph.metrics.horizontalBearingX;
                glyph.yOffset  = tmpGlyph.metrics.horizontalBearingY;
                retn.Add((int)asset.characterTable[i].unicode, glyph);
            }

            return(retn);
        }
コード例 #31
0
ファイル: GameUIController.cs プロジェクト: Slympp/GetOut
        public void InitFonts(TMP_FontAsset font)
        {
            if (font == null)
            {
                Debug.LogError("GameUIController => Font not found for this level.");
                return;
            }

            ActivityName.font = font;
            LevelName.font    = font;

            TMP_Text[] gameOverTexts = GameOverUI.GetComponentsInChildren <TMP_Text>();
            foreach (var text in gameOverTexts)
            {
                text.font = font;
            }

            TMP_Text[] victoryTexts = VictorUI.GetComponentsInChildren <TMP_Text>();
            foreach (var text in victoryTexts)
            {
                text.font = font;
            }
        }
コード例 #32
0
        public void OnEnable()
        {
            font_atlas_prop = serializedObject.FindProperty("atlas");
            font_material_prop = serializedObject.FindProperty("material");

            fontWeights_prop = serializedObject.FindProperty("fontWeights");

            //fontWeight_Thin = serializedObject.FindProperty("thin");
            //fontWeight_ExtraLight = serializedObject.FindProperty("extraLight");
            //fontWeight_Light = serializedObject.FindProperty("light");
            //fontWeight_Normal = serializedObject.FindProperty("normal");
            //fontWeight_Medium = serializedObject.FindProperty("medium");
            //fontWeight_DemiBold = serializedObject.FindProperty("demiBold");
            //fontWeight_Bold = serializedObject.FindProperty("bold");
            //fontWeight_Heavy = serializedObject.FindProperty("heavy");
            //fontWeight_Black = serializedObject.FindProperty("black");

            font_normalStyle_prop = serializedObject.FindProperty("normalStyle");
            font_normalSpacing_prop = serializedObject.FindProperty("normalSpacingOffset");

            font_boldStyle_prop = serializedObject.FindProperty("boldStyle");
            font_boldSpacing_prop = serializedObject.FindProperty("boldSpacing");

            font_italicStyle_prop = serializedObject.FindProperty("italicStyle");
            font_tabSize_prop = serializedObject.FindProperty("tabSize");

            m_fontInfo_prop = serializedObject.FindProperty("m_fontInfo");
            m_glyphInfoList_prop = serializedObject.FindProperty("m_glyphInfoList");
            m_kerningInfo_prop = serializedObject.FindProperty("m_kerningInfo");
            m_kerningPair_prop = serializedObject.FindProperty("m_kerningPair");

            //m_isGlyphInfoListExpanded_prop = serializedObject.FindProperty("isGlyphInfoListExpanded");
            //m_isKerningTableExpanded_prop = serializedObject.FindProperty("isKerningTableExpanded");

            m_fontAsset = target as TMP_FontAsset;
            m_kerningTable = m_fontAsset.kerningInfo;

            // Get the UI Skin and Styles for the various Editors
            TMP_UIStyleManager.GetUIStyles();
        }
コード例 #33
0
        public void OnEnable()
        {
            font_atlas_prop = serializedObject.FindProperty("atlas");
            font_material_prop = serializedObject.FindProperty("material");

            fontWeights_prop = serializedObject.FindProperty("fontWeights");

            m_list = new ReorderableList(serializedObject, serializedObject.FindProperty("fallbackFontAssets"), true, true, true, true);

            m_list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                var element = m_list.serializedProperty.GetArrayElementAtIndex(index);
                rect.y += 2;
                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
            };

            m_list.drawHeaderCallback = rect =>
            {
                EditorGUI.LabelField(rect, "<b>Fallback Font Asset List</b>", TMP_UIStyleManager.Label);
            };

            font_normalStyle_prop = serializedObject.FindProperty("normalStyle");
            font_normalSpacing_prop = serializedObject.FindProperty("normalSpacingOffset");

            font_boldStyle_prop = serializedObject.FindProperty("boldStyle");
            font_boldSpacing_prop = serializedObject.FindProperty("boldSpacing");

            font_italicStyle_prop = serializedObject.FindProperty("italicStyle");
            font_tabSize_prop = serializedObject.FindProperty("tabSize");

            m_fontInfo_prop = serializedObject.FindProperty("m_fontInfo");
            m_glyphInfoList_prop = serializedObject.FindProperty("m_glyphInfoList");
            m_kerningInfo_prop = serializedObject.FindProperty("m_kerningInfo");
            m_kerningPair_prop = serializedObject.FindProperty("m_kerningPair");

            //m_isGlyphInfoListExpanded_prop = serializedObject.FindProperty("isGlyphInfoListExpanded");
            //m_isKerningTableExpanded_prop = serializedObject.FindProperty("isKerningTableExpanded");

            m_fontAsset = target as TMP_FontAsset;
            m_kerningTable = m_fontAsset.kerningInfo;

            // Get the UI Skin and Styles for the various Editors
            TMP_UIStyleManager.GetUIStyles();
        }
コード例 #34
0
        void DrawControls()
        {
            GUILayout.BeginVertical();
            GUILayout.Label("<b>TextMeshPro - Font Asset Creator</b>", TMP_UIStyleManager.Section_Label, GUILayout.Width(300));
            GUILayout.Label("Font Settings", TMP_UIStyleManager.Section_Label, GUILayout.Width(300));

            GUILayout.BeginVertical(TMP_UIStyleManager.TextureAreaBox, GUILayout.Width(300));

            EditorGUIUtility.labelWidth = 120f;
            EditorGUIUtility.fieldWidth = 160f;

            // FONT TTF SELECTION
            EditorGUI.BeginChangeCheck();
            font_TTF = EditorGUILayout.ObjectField("Font Source", font_TTF, typeof(Font), false, GUILayout.Width(290)) as Font;
            if (EditorGUI.EndChangeCheck())
            {
                //
            }

            // FONT SIZING
            if (FontSizingOption_Selection == 0)
            {
                FontSizingOption_Selection = EditorGUILayout.Popup("Font Size", FontSizingOption_Selection, FontSizingOptions, GUILayout.Width(290));
            }
            else
            {

                EditorGUIUtility.labelWidth = 120f;
                EditorGUIUtility.fieldWidth = 40f;

                GUILayout.BeginHorizontal(GUILayout.Width(290));
                FontSizingOption_Selection = EditorGUILayout.Popup("Font Size", FontSizingOption_Selection, FontSizingOptions, GUILayout.Width(225));
                font_size = EditorGUILayout.IntField(font_size);
                GUILayout.EndHorizontal();
            }

            EditorGUIUtility.labelWidth = 120f;
            EditorGUIUtility.fieldWidth = 160f;

            // FONT PADDING
            font_padding = EditorGUILayout.IntField("Font Padding", font_padding, GUILayout.Width(290));
            font_padding = (int)Mathf.Clamp(font_padding, 0f, 64f);

            // FONT PACKING METHOD SELECTION
            m_fontPackingSelection = (FontPackingModes)EditorGUILayout.EnumPopup("Packing Method", m_fontPackingSelection, GUILayout.Width(225));

            //font_renderingMode = (FontRenderingMode)EditorGUILayout.EnumPopup("Rendering Mode", font_renderingMode, GUILayout.Width(290));

            // FONT ATLAS RESOLUTION SELECTION
            GUILayout.BeginHorizontal(GUILayout.Width(290));
            GUI.changed = false;

            EditorGUIUtility.labelWidth = 120f;
            EditorGUIUtility.fieldWidth = 40f;

            GUILayout.Label("Atlas Resolution:", GUILayout.Width(116));
            font_atlas_width = EditorGUILayout.IntPopup(font_atlas_width, FontResolutionLabels, FontAtlasResolutions); //, GUILayout.Width(80));
            font_atlas_height = EditorGUILayout.IntPopup(font_atlas_height, FontResolutionLabels, FontAtlasResolutions); //, GUILayout.Width(80));

            GUILayout.EndHorizontal();

            // FONT CHARACTER SET SELECTION
            GUI.changed = false;
            bool hasSelectionChanged = false;
            font_CharacterSet_Selection = EditorGUILayout.Popup("Character Set", font_CharacterSet_Selection, FontCharacterSets, GUILayout.Width(290));
            if (GUI.changed)
            {
                characterSequence = "";
                hasSelectionChanged = true;
                //Debug.Log("Resetting Sequence!");
            }

            switch (font_CharacterSet_Selection)
            {
                case 0: // ASCII
                    //characterSequence = "32 - 126, 130, 132 - 135, 139, 145 - 151, 153, 155, 161, 166 - 167, 169 - 174, 176, 181 - 183, 186 - 187, 191, 8210 - 8226, 8230, 8240, 8242 - 8244, 8249 - 8250, 8252 - 8254, 8260, 8286";
                    characterSequence = "32 - 126, 160, 8203, 8230, 9633";
                    break;

                case 1: // EXTENDED ASCII
                    characterSequence = "32 - 126, 160 - 255, 8192 - 8303, 8364, 8482, 9633";
                    // Could add 9632 for missing glyph
                    break;

                case 2: // Lowercase
                    characterSequence = "32 - 64, 91 - 126, 160";
                    break;

                case 3: // Uppercase
                    characterSequence = "32 - 96, 123 - 126, 160";
                    break;

                case 4: // Numbers & Symbols
                    characterSequence = "32 - 64, 91 - 96, 123 - 126, 160";
                    break;

                case 5: // Custom Range
                    EditorGUILayout.BeginVertical(TMP_UIStyleManager.TextureAreaBox);
                    GUILayout.Label("Enter a sequence of decimal values to define the characters to be included in the font asset or retrieve one from another font asset.", TMP_UIStyleManager.Label);
                    GUILayout.Space(10f);

                    EditorGUI.BeginChangeCheck();
                    m_fontAssetSelection = EditorGUILayout.ObjectField("Select Font Asset", m_fontAssetSelection, typeof(TMP_FontAsset), false, GUILayout.Width(290)) as TMP_FontAsset;
                    if (EditorGUI.EndChangeCheck() || hasSelectionChanged)
                    {
                        if (m_fontAssetSelection != null)
                            characterSequence = TMP_EditorUtility.GetDecimalCharacterSequence(TMP_FontAsset.GetCharactersArray(m_fontAssetSelection));
                    }

                    EditorGUIUtility.labelWidth = 120;

                    // Filter out unwanted characters.
                    char chr = Event.current.character;
                    if ((chr < '0' || chr > '9') && (chr < ',' || chr > '-'))
                    {
                        Event.current.character = '\0';
                    }
                    GUILayout.Label("Character Sequence (Decimal)", TMP_UIStyleManager.Section_Label);
                    characterSequence = EditorGUILayout.TextArea(characterSequence, TMP_UIStyleManager.TextAreaBoxWindow, GUILayout.Height(120), GUILayout.MaxWidth(290));

                    EditorGUILayout.EndVertical();
                    break;

                case 6: // Unicode HEX Range
                    EditorGUILayout.BeginVertical(TMP_UIStyleManager.TextureAreaBox);
                    GUILayout.Label("Enter a sequence of Unicode (hex) values to define the characters to be included in the font asset or retrieve one from another font asset.", TMP_UIStyleManager.Label);
                    GUILayout.Space(10f);

                    EditorGUI.BeginChangeCheck();
                    m_fontAssetSelection = EditorGUILayout.ObjectField("Select Font Asset", m_fontAssetSelection, typeof(TMP_FontAsset), false, GUILayout.Width(290)) as TMP_FontAsset;
                    if (EditorGUI.EndChangeCheck() || hasSelectionChanged)
                    {
                        if (m_fontAssetSelection != null)
                            characterSequence = TMP_EditorUtility.GetUnicodeCharacterSequence(TMP_FontAsset.GetCharactersArray(m_fontAssetSelection));
                    }

                    EditorGUIUtility.labelWidth = 120;

                    // Filter out unwanted characters.
                    chr = Event.current.character;
                    if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F') && (chr < ',' || chr > '-'))
                    {
                        Event.current.character = '\0';
                    }
                    GUILayout.Label("Character Sequence (Hex)", TMP_UIStyleManager.Section_Label);
                    characterSequence = EditorGUILayout.TextArea(characterSequence, TMP_UIStyleManager.TextAreaBoxWindow, GUILayout.Height(120), GUILayout.MaxWidth(290));

                    EditorGUILayout.EndVertical();
                    break;

                case 7: // Characters from Font Asset
                    EditorGUILayout.BeginVertical(TMP_UIStyleManager.TextureAreaBox);
                    GUILayout.Label("Type the characters to be included in the font asset or retrieve them from another font asset.", TMP_UIStyleManager.Label);
                    GUILayout.Space(10f);

                    EditorGUI.BeginChangeCheck();
                    m_fontAssetSelection = EditorGUILayout.ObjectField("Select Font Asset", m_fontAssetSelection, typeof(TMP_FontAsset), false, GUILayout.Width(290)) as TMP_FontAsset;
                    if (EditorGUI.EndChangeCheck() || hasSelectionChanged)
                    {
                        if (m_fontAssetSelection != null)
                            characterSequence = TMP_FontAsset.GetCharacters(m_fontAssetSelection);
                    }

                    EditorGUIUtility.labelWidth = 120;

                    EditorGUI.indentLevel = 0;

                    GUILayout.Label("Custom Character List", TMP_UIStyleManager.Section_Label);
                    characterSequence = EditorGUILayout.TextArea(characterSequence, TMP_UIStyleManager.TextAreaBoxWindow, GUILayout.Height(120), GUILayout.MaxWidth(290));
                    EditorGUILayout.EndVertical();
                    break;

                case 8: // Character List from File
                    characterList = EditorGUILayout.ObjectField("Character File", characterList, typeof(TextAsset), false, GUILayout.Width(290)) as TextAsset;
                    if (characterList != null)
                    {
                        characterSequence = characterList.text;
                    }
                    break;
            }

            EditorGUIUtility.labelWidth = 120f;
            EditorGUIUtility.fieldWidth = 40f;

            // FONT STYLE SELECTION
            GUILayout.BeginHorizontal(GUILayout.Width(290));
            font_style = (FaceStyles)EditorGUILayout.EnumPopup("Font Style:", font_style, GUILayout.Width(225));
            font_style_mod = EditorGUILayout.IntField((int)font_style_mod);
            GUILayout.EndHorizontal();

            // Render Mode Selection
            font_renderMode = (RenderModes)EditorGUILayout.EnumPopup("Font Render Mode:", font_renderMode, GUILayout.Width(290));

            includeKerningPairs = EditorGUILayout.Toggle("Get Kerning Pairs?", includeKerningPairs, GUILayout.MaxWidth(290));

            EditorGUIUtility.labelWidth = 120f;
            EditorGUIUtility.fieldWidth = 160f;

            GUILayout.Space(20);

            GUI.enabled = font_TTF == null || isProcessing ? false : true;    // Enable Preview if we are not already rendering a font.
            if (GUILayout.Button("Generate Font Atlas", GUILayout.Width(290)) && characterSequence.Length != 0 && GUI.enabled)
            {
                if (font_TTF != null)
                {
                    int error_Code;

                    error_Code = TMPro_FontPlugin.Initialize_FontEngine(); // Initialize Font Engine
                    if (error_Code != 0)
                    {
                        if (error_Code == 99)
                        {
                            //Debug.Log("Font Library was already initialized!");
                            error_Code = 0;
                        }
                        else
                            Debug.Log("Error Code: " + error_Code + "  occurred while Initializing the FreeType Library.");
                    }

                    string fontPath = AssetDatabase.GetAssetPath(font_TTF); // Get file path of TTF Font.

                    if (error_Code == 0)
                    {
                        error_Code = TMPro_FontPlugin.Load_TrueType_Font(fontPath); // Load the selected font.

                        if (error_Code != 0)
                        {
                            if (error_Code == 99)
                            {
                                //Debug.Log("Font was already loaded!");
                                error_Code = 0;
                            }
                            else
                                Debug.Log("Error Code: " + error_Code + "  occurred while Loading the font.");
                        }
                    }

                    if (error_Code == 0)
                    {
                        if (FontSizingOption_Selection == 0) font_size = 72; // If Auto set size to 72 pts.

                        error_Code = TMPro_FontPlugin.FT_Size_Font(font_size); // Load the selected font and size it accordingly.
                        if (error_Code != 0)
                            Debug.Log("Error Code: " + error_Code + "  occurred while Sizing the font.");
                    }

                    // Define an array containing the characters we will render.
                    if (error_Code == 0)
                    {
                        int[] character_Set = null;
                        if (font_CharacterSet_Selection == 7 || font_CharacterSet_Selection == 8)
                        {
                            List<int> char_List = new List<int>();

                            for (int i = 0; i < characterSequence.Length; i++)
                            {
                                // Check to make sure we don't include duplicates
                                if (char_List.FindIndex(item => item == characterSequence[i]) == -1)
                                    char_List.Add(characterSequence[i]);
                                else
                                {
                                    //Debug.Log("Character [" + characterSequence[i] + "] is a duplicate.");
                                }
                            }

                            character_Set = char_List.ToArray();
                        }
                        else if (font_CharacterSet_Selection == 6)
                        {
                            character_Set = ParseHexNumberSequence(characterSequence);
                        }
                        else
                        {
                            character_Set = ParseNumberSequence(characterSequence);
                        }

                        m_character_Count = character_Set.Length;

                        m_texture_buffer = new byte[font_atlas_width * font_atlas_height];

                        m_font_faceInfo = new FT_FaceInfo();

                        m_font_glyphInfo = new FT_GlyphInfo[m_character_Count];

                        int padding = font_padding;

                        bool autoSizing = FontSizingOption_Selection == 0 ? true : false;

                        float strokeSize = font_style_mod;
                        if (font_renderMode == RenderModes.DistanceField16) strokeSize = font_style_mod * 16;
                        if (font_renderMode == RenderModes.DistanceField32) strokeSize = font_style_mod * 32;

                        isProcessing = true;

                        ThreadPool.QueueUserWorkItem(SomeTask =>
                        {
                            isRenderingDone = false;

                            error_Code = TMPro_FontPlugin.Render_Characters(m_texture_buffer, font_atlas_width, font_atlas_height, padding, character_Set, m_character_Count, font_style, strokeSize, autoSizing, font_renderMode,(int)m_fontPackingSelection, ref m_font_faceInfo, m_font_glyphInfo);
                            isRenderingDone = true;
                            //Debug.Log("Font Rendering is completed.");
                        });

                        previewSelection = PreviewSelectionTypes.PreviewFont;

                    }
                }
            }

            // FONT RENDERING PROGRESS BAR
            GUILayout.Space(1);
            progressRect = GUILayoutUtility.GetRect(288, 20, TMP_UIStyleManager.TextAreaBoxWindow, GUILayout.Width(288), GUILayout.Height(20));

            GUI.BeginGroup(progressRect);
            GUI.DrawTextureWithTexCoords(new Rect(2, 0, 288, 20), TMP_UIStyleManager.progressTexture, new Rect(1 - m_renderingProgress, 0, 1, 1));
            GUI.EndGroup();

            // FONT STATUS & INFORMATION
            GUISkin skin = GUI.skin;
            GUI.skin = TMP_UIStyleManager.TMP_GUISkin;

            GUILayout.Space(5);
            GUILayout.BeginVertical(TMP_UIStyleManager.TextAreaBoxWindow);
            output_ScrollPosition = EditorGUILayout.BeginScrollView(output_ScrollPosition, GUILayout.Height(145));
            EditorGUILayout.LabelField(output_feedback, TMP_UIStyleManager.Label);
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUI.skin = skin;

            GUILayout.Space(10);

            // SAVE TEXTURE & CREATE and SAVE FONT XML FILE
            GUI.enabled = m_font_Atlas != null ? true : false;    // Enable Save Button if font_Atlas is not Null.
            if (GUILayout.Button("Save TextMeshPro Font Asset", GUILayout.Width(290)) && GUI.enabled)
            {
                string filePath = string.Empty;

                if (font_renderMode < RenderModes.DistanceField16) // == RenderModes.HintedSmooth || font_renderMode == RenderModes.RasterHinted)
                {
                    filePath = EditorUtility.SaveFilePanel("Save TextMesh Pro! Font Asset File", new FileInfo(AssetDatabase.GetAssetPath(font_TTF)).DirectoryName, font_TTF.name, "asset");

                    if (filePath.Length == 0)
                        return;

                    Save_Normal_FontAsset(filePath);
                }
                else if (font_renderMode >= RenderModes.DistanceField16)
                {
                    filePath = EditorUtility.SaveFilePanel("Save TextMesh Pro! Font Asset File", new FileInfo(AssetDatabase.GetAssetPath(font_TTF)).DirectoryName, font_TTF.name + " SDF", "asset");

                    if (filePath.Length == 0)
                        return;

                    Save_SDF_FontAsset(filePath);
                }

            }

            GUI.enabled = true; // Re-enable GUI

            GUILayout.Space(5);

            GUILayout.EndVertical();

            GUILayout.Space(25);

            /*
            // GENERATE DISTANCE FIELD TEXTURE
            GUILayout.Label("Distance Field Options", SectionLabel, GUILayout.Width(300));

            GUILayout.BeginVertical(textureAreaBox, GUILayout.Width(300));

            GUILayout.Space(5);

            font_spread = EditorGUILayout.IntField("Spread", font_spread, GUILayout.Width(280));
            font_scaledownFactor = EditorGUILayout.IntField("Scale down factor", font_scaledownFactor, GUILayout.Width(280));
            if (GUI.changed)
            {
                EditorPrefs.SetInt("Font_Spread", font_spread);
                EditorPrefs.SetInt("Font_ScaleDownFactor", font_scaledownFactor);
            }

            GUILayout.Space(20);

            GUI.enabled = m_font_Atlas != null ? true : false;    // Enable Save Button if font_Atlas is not Null.
            if (GUILayout.Button("Preview Distance Field Font Atlas", GUILayout.Width(290)))
            {

                if (m_font_Atlas != null && isProcessing == false)
                {
                    // Generate Distance Field
                    int width = m_font_Atlas.width;
                    int height = m_font_Atlas.height;
                    Color[] colors = m_font_Atlas.GetPixels(); // Should modify this to use Color32 instead

                    isProcessing = true;

                    ThreadPool.QueueUserWorkItem(SomeTask => { TMPro_DistanceTransform.Generate(colors, width, height, font_spread, font_scaledownFactor); });

                    previewSelection = PreviewSelectionTypes.PreviewDistanceField;
                }
            }

            GUILayout.Space(1);

            progressRect = GUILayoutUtility.GetRect(290, 20, textAreaBox, GUILayout.Width(290), GUILayout.Height(20));

            GUI.BeginGroup(progressRect);

            GUI.DrawTextureWithTexCoords(new Rect(0, 0, 290, 20), progressTexture, new Rect(1 - ProgressPercentage, 0, 1, 1));
            GUI.EndGroup();

            //GUILayout.Space(5);

            GUI.enabled = m_destination_Atlas != null ? true : false;    // Enable Save Button if font_Atlas is not Null.
            if (GUILayout.Button("Save TextMeshPro (SDF) Font Asset", GUILayout.Width(290)))
            {
                string filePath = EditorUtility.SaveFilePanel("Save TextMesh Pro! Font Asset File", new FileInfo(AssetDatabase.GetAssetPath(font_TTF)).DirectoryName, font_TTF.name + " SDF", "asset");

                if (filePath.Length == 0)
                    return;

                Save_SDF_FontAsset(filePath);

            }

            GUILayout.EndVertical();
            */

            // Figure out the size of the current UI Panel
            Rect rect = EditorGUILayout.GetControlRect(false, 5);
            if (Event.current.type == EventType.Repaint)
                m_UI_Panel_Size = rect;

            GUILayout.EndVertical();
        }