Closed solomode0001 closed 3 months ago
Fixed...
I'm also experiencing this problem, how did you solve it?
So that's the problem here. Here's the modification.
this Code is not working now no errors report and game exit ! this line cause:
auto gameObject = BNM::Class("UnityEngine", "GameObject").CreateNewObjectParameters();
:
struct MyClass : public BNM::UnityEngine::MonoBehaviour {
BNM_CustomClass(MyClass, BNM::CompileTimeClassBuilder("","MyClass").Build(), BNM::CompileTimeClassBuilder("UnityEngine","MonoBehaviour").Build(), {});
void Update() {
LOGI("Call Update");
}
BNM_CustomMethod(Update, false, BNM::GetType<void>(), "Update");
};
BNM::Method<void*> addComponent;
BNM::Method<void> dontDestroyOnLoad;
void *AttachComponent() {
auto gameObject = BNM::Class("UnityEngine", "GameObject").CreateNewObjectParameters();
addComponent[gameObject](MyClass::BNMCustomClass.type);
dontDestroyOnLoad(gameObject);
return gameObject;
}
void OnLoad() {
addComponent = BNM::Class("UnityEngine", "GameObject").GetMethod("AddComponent", {"componentType"});
dontDestroyOnLoad = BNM::Class("UnityEngine", "Object").GetMethod("DontDestroyOnLoad");
auto r = AttachComponent();
}
@solomode0001 @yunli97 can you test the BNM lastest version with the example? ,
Logs:
Code: