Files
DuckovMods/UIFrame/ModBehaviour.cs

72 lines
1.7 KiB
C#
Raw Permalink Normal View History

2025-11-05 21:34:21 +08:00
using System;
using Duckov.Modding;
2025-11-04 17:05:34 +08:00
using Duckov.Options.UI;
2025-11-05 21:34:21 +08:00
using Duckov.UI;
using Duckov.UI.Animations;
using Duckov.Utilities;
using HarmonyLib;
using SodaCraft.Localizations;
using UnityEngine;
namespace UIFrame
{
public class ModBehaviour:Duckov.Modding.ModBehaviour
{
2025-11-05 21:34:21 +08:00
private const string MOD_ID="UIFrame";
private GameObject? workerObject;
private Harmony? harmony;
private void Start()
{
}
protected override void OnAfterSetup()
{
2025-11-05 21:34:21 +08:00
CreateAPIObject();
if (harmony == null)
{
harmony=new HarmonyLib.Harmony(MOD_ID);
}
harmony.PatchAll();
Test();
}
2025-11-05 21:34:21 +08:00
protected override void OnBeforeDeactivate()
{
2025-11-05 21:34:21 +08:00
ClearAPIObject();
harmony?.UnpatchAll(MOD_ID);
harmony = null;
}
private void CreateAPIObject()
{
if(workerObject)
return;
workerObject = new GameObject($"{MOD_ID}_APIObject");
workerObject.AddComponent<UIFrameWorker>();
}
private void ClearAPIObject()
{
if(!workerObject)
return;
Destroy(workerObject);
workerObject = null;
}
private void Test()
{
if(!UIFrameAPI.Initialize())
return;
UIFrameAPI.SetGameTitle(@"D:\doc\植物大战僵尸贴图\images\ad\Logo.png");
// UIFrameAPI.SetGameTitlePosition(Vector3.zero);
UIFrameAPI.SetGameTitleText("开始冒险");
}
}
}