init a bigInjectbag project
This commit is contained in:
@@ -1,20 +1,28 @@
|
||||
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace test
|
||||
{
|
||||
/// <summary>
|
||||
/// test模组的主要行为类
|
||||
/// 继承自Duckov.Modding.ModBehaviour,用于在游戏UI中显示物品价值
|
||||
/// 基础模板
|
||||
/// 继承自Duckov.Modding.ModBehaviour
|
||||
/// </summary>
|
||||
public class ModBehaviour : Duckov.Modding.ModBehaviour
|
||||
{
|
||||
|
||||
private Harmony harmony;
|
||||
|
||||
/// <summary>
|
||||
/// 模组初始化时调用,类似于构造函数
|
||||
/// </summary>
|
||||
void Awake()
|
||||
{
|
||||
|
||||
// 初始化Harmony实例
|
||||
harmony = new Harmony("com.test.all.patches");
|
||||
|
||||
// 应用所有Harmony补丁
|
||||
harmony.PatchAll();
|
||||
|
||||
Debug.Log("Test模组已加载,所有补丁已应用");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -22,12 +30,18 @@ namespace test
|
||||
/// </summary>
|
||||
void OnDestroy()
|
||||
{
|
||||
|
||||
// 卸载所有Harmony补丁
|
||||
harmony?.UnpatchAll();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
// 模组启用时重新应用补丁
|
||||
if (harmony == null)
|
||||
{
|
||||
harmony = new Harmony("com.test.all.patches");
|
||||
harmony.PatchAll();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +50,9 @@ namespace test
|
||||
/// </summary>
|
||||
void OnDisable()
|
||||
{
|
||||
|
||||
// 模组禁用时卸载补丁
|
||||
harmony?.UnpatchAll();
|
||||
harmony = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user