Improve Il2Cpp Coroutine support, make universal ExplorerBehaviour class

This commit is contained in:
Sinai
2021-05-01 20:55:14 +10:00
parent d6cde68a44
commit ab8b736f7e
13 changed files with 112 additions and 98 deletions

View File

@ -57,53 +57,23 @@ namespace UnityExplorer
{
Instance = this;
_configHandler = new BepInExConfigHandler();
ExplorerCore.Init(this);
}
#if MONO // Mono-specific
#if MONO // Mono
internal void Awake()
{
UniversalInit();
ExplorerCore.Init(this);
}
internal void Update()
{
ExplorerCore.Update();
}
#else // Il2Cpp-specific
#else // Il2Cpp
public override void Load()
{
UniversalInit();
ClassInjector.RegisterTypeInIl2Cpp<ExplorerBehaviour>();
var obj = new GameObject("ExplorerBehaviour");
obj.AddComponent<ExplorerBehaviour>();
obj.hideFlags = HideFlags.HideAndDontSave;
GameObject.DontDestroyOnLoad(obj);
ExplorerCore.Init(this);
}
// BepInEx Il2Cpp mod class doesn't have monobehaviour methods yet, so wrap them in a dummy.
public class ExplorerBehaviour : MonoBehaviour
{
public ExplorerBehaviour(IntPtr ptr) : base(ptr) { }
internal void Awake()
{
Instance.LogSource.LogMessage("ExplorerBehaviour.Awake");
}
internal void Update()
{
ExplorerCore.Update();
}
}
#endif
public void SetupPatches()
public void SetupCursorPatches()
{
try
{

View File

@ -17,6 +17,6 @@ namespace UnityExplorer
Action<object> OnLogWarning { get; }
Action<object> OnLogError { get; }
void SetupPatches();
void SetupCursorPatches();
}
}

View File

@ -41,12 +41,12 @@ namespace UnityExplorer
ExplorerCore.Init(this);
}
public override void OnUpdate()
{
ExplorerCore.Update();
}
//public override void OnUpdate()
//{
// ExplorerCore.Update();
//}
public void SetupPatches()
public void SetupCursorPatches()
{
try
{

View File

@ -87,30 +87,10 @@ namespace UnityExplorer
Instance = this;
_configHandler = new StandaloneConfigHandler();
#if CPP
ClassInjector.RegisterTypeInIl2Cpp<ExplorerBehaviour>();
#endif
var obj = new GameObject("ExplorerBehaviour");
obj.AddComponent<ExplorerBehaviour>();
GameObject.DontDestroyOnLoad(obj);
obj.hideFlags = HideFlags.HideAndDontSave;
ExplorerCore.Init(this);
}
public class ExplorerBehaviour : MonoBehaviour
{
#if CPP
public ExplorerBehaviour(IntPtr ptr) : base(ptr) { }
#endif
internal void Update()
{
ExplorerCore.Update();
}
}
public void SetupPatches()
public void SetupCursorPatches()
{
try
{