Exemple #1
0
        public FontAsset GetFont(string path, bool tryReloading = false)
        {
            // will be present & null if loaded but not resolved
            if (s_FontMap.TryGetValue(path, out FontAsset fontAsset))
            {
                if (fontAsset != null)
                {
                    return(fontAsset);
                }

                if (!tryReloading)
                {
                    return(null);
                }
            }

            TMP_FontAsset tmpFontAsset = Resources.Load <TMP_FontAsset>(path);

            if (tmpFontAsset == null)
            {
                s_FontMap.Add(path, null);
                return(null);
            }

            if (tmpFontAsset.fontAssetType != TMP_FontAsset.FontAssetTypes.SDF)
            {
                throw new Exception($"UIForia currently supports only SDF Fonts. {path} is not an SDF font, please reference another");
            }

            FontAsset retn = new FontAsset(tmpFontAsset);

            s_FontMap.Add(path, retn);

            return(retn);
        }
Exemple #2
0
//        public FontAsset AddFont(TMP_FontAsset font) {
//            return AddResource(font, s_FontMap);
//        }

        public FontAsset AddFont(string path, TMP_FontAsset font)
        {
            if (font == null || path == null)
            {
                return(null);
            }

            FontAsset asset = new FontAsset(font);

            s_FontMap.Add(path, asset);
            return(asset);
        }