mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System.IO;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace ConformalDecals.Text {
|
|
|
|
[DatabaseLoaderAttrib(new[] {"kspfont"})]
|
|
public class FontLoader : DatabaseLoader<GameDatabase.TextureInfo> {
|
|
public static List<TMP_FontAsset> fonts;
|
|
|
|
public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) {
|
|
fonts ??= new List<TMP_FontAsset>();
|
|
|
|
Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'");
|
|
var bundle = AssetBundle.LoadFromFile(urlFile.fullPath);
|
|
if (!bundle) {
|
|
Debug.Log($"[ConformalDecals] could not load font asset {urlFile.fullPath}");
|
|
}
|
|
else {
|
|
var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>();
|
|
foreach (var font in loadedFonts) {
|
|
Debug.Log($"[ConformalDecals] adding font {font.name}" );
|
|
fonts.Add(font);
|
|
Debug.Log($"ConformalDecals] isReadable: {font.atlas.isReadable}");
|
|
}
|
|
}
|
|
|
|
yield break;
|
|
}
|
|
}
|
|
} |