Closed m2k2v closed 12 months ago
my_method must be static
A method needs to be static to be called without an instance. This is generally (if not always) the same for every language.
You can get the loaded instances of a class with Il2Cpp.gc.choose(assembly.class('class_one'))
which returns an array you can filter.
If the method doesn't need to be part of a specific class you should be able to do something like
const obj = assembly.class('class_one').new();
obj.method('whatever').invoke();
or
const obj = assembly.class('class_one').alloc();
obj.method('.ctor').invoke();
obj.method('whatever').invoke();
If it doesn't have a default constructor to create a new object.
hi. I have some problems with invoking methods from another class. this is my code :
AssemblyCSharp.class("class_one").method("alex_methods").implementation = function(this: Il2Cpp.Class | Il2Cpp.Object, param, a, b, c){ // Checks some Ifs. then : AssemblyCSharp.class("another_class").method("my_method").invoke(1) }
Error : cannot invoke non-static method my_method as it must be invoked throught a Il2Cpp.Object, not a Il2Cpp.Class