2025-11-13 16:24:49 +08:00
|
|
|
|
using UnityEngine;
|
2025-11-08 14:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
namespace SceneView
|
|
|
|
|
|
{
|
2025-11-13 16:24:49 +08:00
|
|
|
|
public class ModBehaviour : Duckov.Modding.ModBehaviour
|
2025-11-08 14:03:17 +08:00
|
|
|
|
{
|
2025-11-13 16:24:49 +08:00
|
|
|
|
// public const string MOD_ID="SceneView";
|
|
|
|
|
|
// private Harmony? harmony;
|
|
|
|
|
|
|
2025-11-08 14:03:17 +08:00
|
|
|
|
private GameObject? component;
|
|
|
|
|
|
private CanvasControl myCanvas;
|
2025-11-13 16:24:49 +08:00
|
|
|
|
|
2025-11-08 14:03:17 +08:00
|
|
|
|
protected override void OnAfterSetup()
|
|
|
|
|
|
{
|
|
|
|
|
|
CreateComponents();
|
2025-11-13 16:24:49 +08:00
|
|
|
|
// if (harmony == null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// harmony=new Harmony(MOD_ID);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// harmony.PatchAll();
|
2025-11-08 14:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnBeforeDeactivate()
|
|
|
|
|
|
{
|
|
|
|
|
|
RemoveComponents();
|
2025-11-13 16:24:49 +08:00
|
|
|
|
// if (harmony != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// harmony.UnpatchAll(harmony.Id);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// harmony = null;
|
2025-11-08 14:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CreateComponents()
|
|
|
|
|
|
{
|
2025-11-13 16:24:49 +08:00
|
|
|
|
if (component == null)
|
2025-11-08 14:03:17 +08:00
|
|
|
|
{
|
|
|
|
|
|
component = new GameObject("SceneViewControl");
|
2025-11-13 16:24:49 +08:00
|
|
|
|
myCanvas = component.AddComponent<CanvasControl>();
|
2025-11-08 14:03:17 +08:00
|
|
|
|
component.SetActive(true);
|
|
|
|
|
|
DontDestroyOnLoad(component);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RemoveComponents()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (component != null)
|
|
|
|
|
|
{
|
2025-11-13 16:24:49 +08:00
|
|
|
|
Destroy(component);
|
2025-11-08 14:03:17 +08:00
|
|
|
|
component = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|