From d95935d140f16e799ec14e8b5ae3d0ab5fd84487 Mon Sep 17 00:00:00 2001 From: davud Date: Sun, 23 Aug 2026 23:01:53 +0200 Subject: [PATCH] fix: fixed invisible text and add #5 --- IngameReveries/IngameReveries.cs | 49 +++++++++++++++++++--------- IngameReveries/IngameReveries.csproj | 4 +++ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/IngameReveries/IngameReveries.cs b/IngameReveries/IngameReveries.cs index 0077aa0..f6f8d5c 100644 --- a/IngameReveries/IngameReveries.cs +++ b/IngameReveries/IngameReveries.cs @@ -1,5 +1,6 @@ using System.IO; using System.Linq; +using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; @@ -19,7 +20,7 @@ namespace IngameReveries private void Awake() { // Metadata of your mod is stored in this.about - Debug.Log("Xin Chao! I'm loaded! " + mod.metadata.id); + Debug.Log("Hallo! I'm loaded! " + mod.metadata.id); // If you need to patch with Harmony, you can use this.harmony to access the Harmony instance for your mod. // It will be created with your mod's id automatically, the first time you access the property. @@ -71,20 +72,6 @@ namespace IngameReveries var reveries = _ingameReveriesUI.GetComponent(); - var rect = _ingameReveriesUI.GetComponent(); - rect.anchorMin = new Vector2(0f, 1f); - rect.anchorMax = new Vector2(0f, 1f); - rect.pivot = new Vector2(0f, 1f); - rect.anchoredPosition = new Vector2(+70f, -70f); - } - }; - } - - private void OnDestroy() - { - // Make sure you clean up properly to support Live Reload. - Debug.Log("Good bye! " + mod.metadata.id); - harmony.UnpatchAll(); // Show reveries window var canvasGroup = _ingameReveriesUI.GetComponent(); canvasGroup.alpha = 1f; @@ -97,6 +84,8 @@ namespace IngameReveries rect.anchorMax = new Vector2(0f, 1f); rect.pivot = new Vector2(0f, 1f); rect.anchoredPosition = new Vector2(+70f, -70f); + + FixFonts(); } } @@ -151,5 +140,35 @@ namespace IngameReveries Debug.Log("[IngameReveries] Successfully loaded prefab!"); } + + private void FixFonts() + { + // Get all fonts + TMP_FontAsset[] loadedFonts = Resources.FindObjectsOfTypeAll(); + + // Get all text from the reveries window + TMP_Text[] textComponents = _ingameReveriesUI.GetComponentsInChildren(true); + foreach (TMP_Text textComp in textComponents) + { + if (textComp.font == null) continue; + + string originalFontName = textComp.font.name; + + // Match the font by name, ensuring we don't pick the dead assetbundle version + foreach (TMP_FontAsset loadedFont in loadedFonts) + { + // Pick a matching font that has an active atlas/material + if (loadedFont.name == originalFontName && loadedFont.atlasTexture != null) + { + textComp.font = loadedFont; + + // Force TMP to update its internal mesh and material reference + textComp.ForceMeshUpdate(); + textComp.SetAllDirty(); + break; + } + } + } + } } } \ No newline at end of file diff --git a/IngameReveries/IngameReveries.csproj b/IngameReveries/IngameReveries.csproj index bfa6ee0..c671fc3 100644 --- a/IngameReveries/IngameReveries.csproj +++ b/IngameReveries/IngameReveries.csproj @@ -235,6 +235,10 @@ $(GameManagedDir)\UnityEngine.UI.dll False + + $(GameManagedDir)\UnityEngine.UIModule.dll + False + $(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll False