Replies: 4 comments
-
Yes, you got it right. Afaik, there's no way to pass a pointer to a I don't actually remember if I already tried this, but you can try cloning a
This exactly what I do here. I choose
I do not have the answer to this question. My understanding is delegates are only allowed to call managed code (i.e. C#), not the unmanaged one. I know this doesn't make sense as everything is transpiled to C++ at the end, but this is the behaviour we have. |
Beta Was this translation helpful? Give feedback.
-
What about I played a bit with it and can indeed create a delegate by passing a pointer to my NativeCallback and a type |
Beta Was this translation helpful? Give feedback.
-
Il2Cpp.Api._resolveInternalCall(Memory.allocUtf8String("System.Runtime.InteropServices.Marshal::GetDelegateForFunctionPointerInternal")); So I didn't really played with it as it can't be used. |
Beta Was this translation helpful? Give feedback.
-
After taking a closer look, I still believe that workaround is actually the best approach |
Beta Was this translation helpful? Give feedback.
-
Is it possible to instantiate delegates with their method handlers pointing to a custom NativeCallback instead of an already existent MethodInfo?
Take as an example the following scenario:
– I want to create a System.Action object, called myAction, to pass as the Then callback of a Promise (
Promise.Then(myAction)
).– Once the Promise completes, I want it's callback to invoke a normal NativeCallback of mine.
– I can instantiate a System.Action(object, methodHandler) object if I pass a MethodInfo as the methodHandler, but trying to pass the pointer of a NativeCallback doesn't work.
I'm aware I could workaround that by passing any MethodInfo, intercepting it's call and detaching the interceptor immediately after it fires, but my main goal here is understanding exactly how does the pointer of a method info differs from the pointer of a native callback when it comes to the invocation of a delegate.
Even if this might not be feasible in practice, what would the actual solution be? Could I create my own "bogus" MethodInfo just so the game accepts it? Maybe create a delegate with some sort of helper function? Or perhaps this is not even possible given Il2Cpp constructs the array of methodinfos from within the global metadata file?
Beta Was this translation helpful? Give feedback.
All reactions