Files
sod-ingame-reveries/IngameReveries/IngameReveries.cs
T
2026-08-23 13:12:20 +02:00

62 lines
2.2 KiB
C#

using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace IngameReveries
{
// ModBehaviour will be instantiated and attached as a component in a container game object named <Your Mod ID>
// Multiple ModBehaviours in your mod will share the same container.
public class IngameReveries : ModBehaviour
{
private GameObject _ingameReveriesUI;
private void Awake()
{
// Metadata of your mod is stored in this.about
Debug.Log("Hola! 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.
harmony.PatchAll();
}
private void Start()
{
SceneManager.sceneLoaded += (scene, mode) =>
{
// Check if UI already instantiated
if (_ingameReveriesUI != null)
{
return;
}
string gameSceneDir = "Assets/Dew/Zones/";
string relativeToScene = Path.GetRelativePath(gameSceneDir, scene.path);
if (!relativeToScene.StartsWith(".."))
{
Debug.Log($"[IngameReveries] Switched to scene inside {gameSceneDir}");
GameObject menuViewGO = GameObject.Find("GameLogicPackage/UI/InGame/UI_Common_MenuView");
if (menuViewGO == null)
{
Debug.Log("Couldn't find menu view");
return;
}
_ingameReveriesUI = new GameObject("IngameReveriesUI");
_ingameReveriesUI.transform.parent = menuViewGO.transform;
Instantiate(DewGUI.widgetWindow, _ingameReveriesUI.transform);
}
};
}
private void OnDestroy()
{
// Make sure you clean up properly to support Live Reload.
Debug.Log("Good bye! " + mod.metadata.id);
harmony.UnpatchAll();
}
}
}