Compare commits

...
3 Commits
Author SHA1 Message Date
david 2820d0860b fix: first reverie not clickable
moved reveries window down because i don't want to search for a gameobject that blocks the reveries window at that specific point.
2026-08-23 23:03:25 +02:00
david d95935d140 fix: fixed invisible text and add #5 2026-08-23 23:01:53 +02:00
david 7a1227d588 refactor: pull out method
pull out event to be able to unsubscribe from it when mod is unloaded
2026-08-23 22:59:26 +02:00
2 changed files with 86 additions and 37 deletions
+57 -12
View File
@@ -1,7 +1,9 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace IngameReveries namespace IngameReveries
@@ -18,7 +20,7 @@ namespace IngameReveries
private void Awake() private void Awake()
{ {
// Metadata of your mod is stored in this.about // Metadata of your mod is stored in this.about
Debug.Log("Xin Chao! I'm loaded! " + mod.metadata.id); Debug.Log("Hello! 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. // 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. // It will be created with your mod's id automatically, the first time you access the property.
@@ -29,7 +31,19 @@ namespace IngameReveries
{ {
InitializeAssets(); InitializeAssets();
SceneManager.sceneLoaded += (scene, mode) => SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDestroy()
{
// Make sure you clean up properly to support Live Reload.
Debug.Log("Good bye! " + mod.metadata.id);
harmony.UnpatchAll();
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
// Check if UI already instantiated // Check if UI already instantiated
if (_ingameReveriesUI != null) if (_ingameReveriesUI != null)
@@ -54,24 +68,25 @@ namespace IngameReveries
_ingameReveriesUI = Instantiate(_reveriesPrefab, menuViewGO.transform); _ingameReveriesUI = Instantiate(_reveriesPrefab, menuViewGO.transform);
_ingameReveriesUI.SetActive(true); _ingameReveriesUI.SetActive(true);
_ingameReveriesUI.name = "IngameReveriesUI"; _ingameReveriesUI.name = "IngameReveriesUI";
_ingameReveriesUI.transform.SetAsFirstSibling(); _ingameReveriesUI.transform.SetSiblingIndex(1);
var reveries = _ingameReveriesUI.GetComponent<UI_Reveries>(); var reveries = _ingameReveriesUI.GetComponent<UI_Reveries>();
// Show reveries window
var canvasGroup = _ingameReveriesUI.GetComponent<CanvasGroup>();
canvasGroup.alpha = 1f;
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
// Position reveries window top left
var rect = _ingameReveriesUI.GetComponent<RectTransform>(); var rect = _ingameReveriesUI.GetComponent<RectTransform>();
rect.anchorMin = new Vector2(0f, 1f); rect.anchorMin = new Vector2(0f, 1f);
rect.anchorMax = new Vector2(0f, 1f); rect.anchorMax = new Vector2(0f, 1f);
rect.pivot = new Vector2(0f, 1f); rect.pivot = new Vector2(0f, 1f);
rect.anchoredPosition = new Vector2(+70f, -70f); rect.anchoredPosition = new Vector2(+70f, -400f);
}
};
}
private void OnDestroy() FixFonts();
{ }
// Make sure you clean up properly to support Live Reload.
Debug.Log("Good bye! " + mod.metadata.id);
harmony.UnpatchAll();
} }
private void InitializeAssets() private void InitializeAssets()
@@ -125,5 +140,35 @@ namespace IngameReveries
Debug.Log("[IngameReveries] Successfully loaded prefab!"); Debug.Log("[IngameReveries] Successfully loaded prefab!");
} }
private void FixFonts()
{
// Get all fonts
TMP_FontAsset[] loadedFonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
// Get all text from the reveries window
TMP_Text[] textComponents = _ingameReveriesUI.GetComponentsInChildren<TMP_Text>(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;
}
}
}
}
} }
} }
+4
View File
@@ -235,6 +235,10 @@
<HintPath>$(GameManagedDir)\UnityEngine.UI.dll</HintPath> <HintPath>$(GameManagedDir)\UnityEngine.UI.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(GameManagedDir)\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.XR.LegacyInputHelpers"> <Reference Include="UnityEngine.XR.LegacyInputHelpers">
<HintPath>$(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll</HintPath> <HintPath>$(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll</HintPath>
<Private>False</Private> <Private>False</Private>