You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.
Game has PlayerCharacter with property myUtilities[] (as Il2CppReferenceArray) of base type BaseUtilityComponent. Said class exposes base property myInputs which is "unhollowed" as Il2CppStructArray<INPUT> where INPUT is plain enum.
Original types from metadata are plain arrays.
I have created my custom class MyUtility and inherited from BaseUtilityComponent on mono side (bepinex plugin)
Upon initialization of PlayerCharacter I instantiate my custom component on mono side, add it to GameObject of PlayerCharacter and add it to myUtilities[] as well
Finally, I populate myInputs with custom array of INPUT enum values.
All these objects are created on a stack in Postfix method so they are collected eventually on mono side and I'm assuming they are copied to il2cpp domain through its boxing/unboxing.
For the first time (first scene load) everything works fine. When I change the scene, thing become weird, myInputs on my custom Component now has some weird garbage data, like Count/Length being a few million or throwing nullref when trying to request any value by index. The odd part is that this component isnt even transitioned through scene as DDOL or HideandDontSave, it is literally recreated as PlayerCharacter is being remade. WasCollected returns false for the given IL2cppStructArray (sine it is referenced on il2cpp side)
Let me know if more information is needed.
The text was updated successfully, but these errors were encountered:
ClassInjector.RegisterTypeInIl2Cpp<MyUtility>();//------publicclassMyUtility:BaseUtility// class from the unhollowed assembly, Monobehaviour{publicMyUtility(System.IntPtr ptr):base(ptr){myInputs=new INPUT[]{//whatever }; // implicit conversion to UnhollowerBaseLib.Il2CppStructArray<T>}publicoverridevoidActionEffect(){
UnityEngine.Debug.Log("DONE");}[HarmonyPatch(typeof(PlayerCharacter),"creature_Awake")]static class PatchPlayerCharacterInit
{staticvoidPostfix(PlayerCharacter__instance){
__instance.gameObject.AddComponent<MyUtility>();//Automatically gets added to IL2cppReferenceArray<BaseUtility>///on character instance by original code}}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
PlayerCharacter
with propertymyUtilities[]
(as Il2CppReferenceArray) of base typeBaseUtilityComponent
. Said class exposes base propertymyInputs
which is "unhollowed" asIl2CppStructArray<INPUT>
whereINPUT
is plain enum.MyUtility
and inherited fromBaseUtilityComponent
on mono side (bepinex plugin)PlayerCharacter
I instantiate my custom component on mono side, add it to GameObject ofPlayerCharacter
and add it tomyUtilities[]
as wellmyInputs
with custom array ofINPUT
enum values.For the first time (first scene load) everything works fine. When I change the scene, thing become weird,
myInputs
on my custom Component now has some weird garbage data, like Count/Length being a few million or throwing nullref when trying to request any value by index. The odd part is that this component isnt even transitioned through scene as DDOL or HideandDontSave, it is literally recreated asPlayerCharacter
is being remade. WasCollected returns false for the givenIL2cppStructArray
(sine it is referenced on il2cpp side)Let me know if more information is needed.
The text was updated successfully, but these errors were encountered: