mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
changes
This commit is contained in:
parent
0a77ef57b7
commit
96c625f6f2
@ -22,8 +22,6 @@ namespace ConformalDecals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void SetText(string newText) {
|
private void SetText(string newText) {
|
||||||
if (!HighLogic.LoadedSceneIsEditor) return;
|
|
||||||
|
|
||||||
this.Log("Rendering text for part");
|
this.Log("Rendering text for part");
|
||||||
var fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
var fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace ConformalDecals.Text {
|
|
||||||
public class DecalFont : ScriptableObject {
|
|
||||||
[SerializeField] public string foo1;
|
|
||||||
[SerializeField] public string foo2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,17 +2,21 @@ using System.IO;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using UniLinq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ConformalDecals.Text {
|
namespace ConformalDecals.Text {
|
||||||
|
|
||||||
[DatabaseLoaderAttrib(new[] {"kspfont"})]
|
[DatabaseLoaderAttrib(new[] {"kspfont"})]
|
||||||
public class FontLoader : DatabaseLoader<GameDatabase.TextureInfo> {
|
public class FontLoader : DatabaseLoader<GameDatabase.TextureInfo> {
|
||||||
public static List<TMP_FontAsset> fonts;
|
private const string FallbackName = "NotoSans-Regular SDF";
|
||||||
|
private static TMP_FontAsset _fallbackFont;
|
||||||
|
|
||||||
public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) {
|
public override IEnumerator Load(UrlDir.UrlFile urlFile, FileInfo fileInfo) {
|
||||||
fonts ??= new List<TMP_FontAsset>();
|
if (_fallbackFont == null) {
|
||||||
|
_fallbackFont = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First(o => o.name == FallbackName);
|
||||||
|
if (_fallbackFont == null) Debug.LogError($"Could not find fallback font '{FallbackName}'");
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'");
|
Debug.Log($"[ConformalDecals] '{urlFile.fullPath}'");
|
||||||
var bundle = AssetBundle.LoadFromFile(urlFile.fullPath);
|
var bundle = AssetBundle.LoadFromFile(urlFile.fullPath);
|
||||||
if (!bundle) {
|
if (!bundle) {
|
||||||
@ -21,12 +25,11 @@ namespace ConformalDecals.Text {
|
|||||||
else {
|
else {
|
||||||
var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>();
|
var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>();
|
||||||
foreach (var font in loadedFonts) {
|
foreach (var font in loadedFonts) {
|
||||||
Debug.Log($"[ConformalDecals] adding font {font.name}" );
|
Debug.Log($"[ConformalDecals] adding font {font.name}");
|
||||||
fonts.Add(font);
|
font.fallbackFontAssets.Add(_fallbackFont);
|
||||||
Debug.Log($"ConformalDecals] isReadable: {font.atlas.isReadable}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user