using FairyGUI; using System.Threading.Tasks; using UnityEngine; using YooAsset; namespace GFGGame { public class FontLoader : SingletonBase { public async Task Init() { Font font0 = await LoadFontAsync(ResPathUtil.GetFontPath("FangZhengHeiTiJianTi-1", "ttf")); FontManager.RegisterFont(new DynamicFont("FangZhengHeiTiJianTi-1", font0)); Font font1 = await LoadFontAsync(ResPathUtil.GetFontPath("FZKTJW--GB1-0", "ttf")); FontManager.RegisterFont(new DynamicFont("FZKTJW--GB1-0", font1)); Font font2 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-Regular-1", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Regular-1", font2)); Font font3 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-Bold-2", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Bold-2", font3)); Font font4 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-ExtraLight-3", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-ExtraLight-3", font4)); Font font5 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-Heavy-4", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Heavy-4", font5)); Font font6 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-Light-5", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Light-5", font6)); Font font7 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-Medium-6", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Medium-6", font7)); Font font8 = await LoadFontAsync(ResPathUtil.GetFontPath("SourceHanSerifCN-SemiBold-7", "otf")); FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-SemiBold-7", font8)); } private async Task LoadFontAsync(string resPath) { AssetOperationHandle handle = YooAssets.LoadAssetAsync(resPath); await handle.Task; return handle.AssetObject as Font; } } }