Closed robertnisipeanu closed 3 years ago
I was having the same problem, then I tried SceneInstance instead, it worked. Try this:
if (il2cppi_is_initialized(SceneInstance__TypeInfo)) {
auto activeScene = app::SceneManager_GetActiveScene(nullptr);
std::cout << "\nActive Scene pointer: " << activeScene.m_Handle << std::endl;
auto activeSceneBoxed = (SceneInstance__Boxed*)il2cpp_value_box((Il2CppClass*)*app::SceneInstance__TypeInfo, &activeScene);
auto activeSceneBoxedNew = (Scene__Boxed*)il2cpp_value_box((Il2CppClass*)*app::SceneInstance__TypeInfo, &activeSceneBoxed->fields.m_Scene);
auto sceneName = app::Scene_get_name(activeSceneBoxedNew, nullptr);
auto sceneNameCpp = il2cppi_to_string(sceneName);
std::cout << "Current scene: " << sceneNameCpp.c_str() << std::endl;
}
@femanso thanks for the answer. Unfortunately, I didn't have time (and I still don't) to set up everything so I can check your solution, but I'll assume this was it.
I'll close the issue now
I'm trying to convert a normal value to a boxed one (Scene to Scene__Boxed), however I can't seem to understand how to correctly do that nor find any documentation on how to do it.
main.cpp:
Game crashes when calling il2cpp_value_box and trying to convert the Scene object into a Scene__Boxed pointer. What is the proper way to get a boxed pointer from a non-boxed variable?