diff --git a/Source/ConformalDecals/ModuleConformalText.cs b/Source/ConformalDecals/ModuleConformalText.cs index 659b694..12953a6 100644 --- a/Source/ConformalDecals/ModuleConformalText.cs +++ b/Source/ConformalDecals/ModuleConformalText.cs @@ -22,8 +22,6 @@ namespace ConformalDecals { } private void SetText(string newText) { - if (!HighLogic.LoadedSceneIsEditor) return; - this.Log("Rendering text for part"); var fonts = Resources.FindObjectsOfTypeAll(); diff --git a/Source/ConformalDecals/Text/DecalFont.cs b/Source/ConformalDecals/Text/DecalFont.cs deleted file mode 100644 index b61d2bb..0000000 --- a/Source/ConformalDecals/Text/DecalFont.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace ConformalDecals.Text { - public class DecalFont : ScriptableObject { - [SerializeField] public string foo1; - [SerializeField] public string foo2; - } -} \ No newline at end of file diff --git a/Source/ConformalDecals/Text/FontLoader.cs b/Source/ConformalDecals/Text/FontLoader.cs index 7b57228..76351cb 100644 --- a/Source/ConformalDecals/Text/FontLoader.cs +++ b/Source/ConformalDecals/Text/FontLoader.cs @@ -2,17 +2,21 @@ using System.IO; using System.Collections; using System.Collections.Generic; using TMPro; +using UniLinq; using UnityEngine; namespace ConformalDecals.Text { - [DatabaseLoaderAttrib(new[] {"kspfont"})] public class FontLoader : DatabaseLoader { - public static List fonts; - + private const string FallbackName = "NotoSans-Regular SDF"; + private static TMP_FontAsset _fallbackFont; + public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) { - fonts ??= new List(); - + if (_fallbackFont == null) { + _fallbackFont = Resources.FindObjectsOfTypeAll().First(o => o.name == FallbackName); + if (_fallbackFont == null) Debug.LogError($"Could not find fallback font '{FallbackName}'"); + } + Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'"); var bundle = AssetBundle.LoadFromFile(urlFile.fullPath); if (!bundle) { @@ -21,12 +25,11 @@ namespace ConformalDecals.Text { else { var loadedFonts = bundle.LoadAllAssets(); foreach (var font in loadedFonts) { - Debug.Log($"[ConformalDecals] adding font {font.name}" ); - fonts.Add(font); - Debug.Log($"ConformalDecals] isReadable: {font.atlas.isReadable}"); + Debug.Log($"[ConformalDecals] adding font {font.name}"); + font.fallbackFontAssets.Add(_fallbackFont); } } - + yield break; } }