Finalize Mod #8

Merged
david merged 17 commits from dev into main 2026-08-24 17:20:17 +02:00
Showing only changes of commit 7a1227d588 - Show all commits
+28 -2
View File
@@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace IngameReveries namespace IngameReveries
@@ -29,7 +30,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,7 +67,7 @@ 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>();
@@ -72,6 +85,19 @@ namespace IngameReveries
// Make sure you clean up properly to support Live Reload. // Make sure you clean up properly to support Live Reload.
Debug.Log("Good bye! " + mod.metadata.id); Debug.Log("Good bye! " + mod.metadata.id);
harmony.UnpatchAll(); harmony.UnpatchAll();
// 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>();
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 InitializeAssets() private void InitializeAssets()