49 lines
955 B
C#
49 lines
955 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace BITKit.Mod
|
|
{
|
|
public class UnityModServiceTester : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public class TestLogGameTickMod:MyMod
|
|
{
|
|
public override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
GameTickService.Add(OnTick);
|
|
}
|
|
private static void OnTick(float obj)
|
|
{
|
|
BIT4Log.Log<TestLogGameTickMod>($"On Test Mod Tick,delta:{obj}");
|
|
}
|
|
public override void OnDispose()
|
|
{
|
|
GameTickService.Remove(OnTick);
|
|
}
|
|
}
|
|
|
|
[SerializeReference, SubclassSelector] private IMod[] initialMods;
|
|
private void OnEnable()
|
|
{
|
|
foreach (var testMod in initialMods)
|
|
{
|
|
ModService.Install(testMod);
|
|
ModService.Load(testMod);
|
|
}
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
foreach (var testMod in initialMods)
|
|
{
|
|
ModService.UnLoad(testMod);
|
|
ModService.UnInstall(testMod);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|