-
How would I create an Action with a Method from a class as the Action? In C# it would be something like Is there a way to make that using BNM? A method I need to call needs an |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
BNM::UnityEngine::UnityAction * |
Beta Was this translation helpful? Give feedback.
-
Using ClassesManagment you can create method: struct HelperClass : BNM::IL2CPP::Il2CppObject {
BNM_CustomClass(HelperClass, BNM::CompileTimeClassBuilder(nullptr, "HelperClass").Build(), {}, {});
static void HelperMethod(void *object) {
BNM_LOG_INFO("HelperMethod: %p", object);
}
BNM_CustomMethod(HelperMethod, true, BNM::Defaults::Get<void>(), "HelperMethod", BNM::Defaults::Get<void *>());
}; Then get class of Action that you need and create new action object: auto actionObject = BNM::Class("System", "Action`1", BNM::Image("mscorlib.dll")).GetGeneric({BNM::Defaults::Get<void *>() /*System.Object*/});
auto newAction = (Mono::Action<void *> *) actionObject.CreateNewObjectParameters(nullptr /*instance*/, HelperClass::BNMCustomMethod_HelperMethod.myInfo); |
Beta Was this translation helpful? Give feedback.
Using ClassesManagment you can create method:
Then get class of Action that you need and create new action object: