I need to completly unload Unity - so I am using UnityCleanup()…
But how to unregister all mono modules? (cause I would like to start up unity from scratch again)…
Without unregister I got crash on second startup - may be some other method must be called?
You are doing that in the Unity Editor? And is there such thing as UnityCleanup() function. I don’t see it in the scripting reference. What are you trying to do then?
Just write a function that does the same the register modules function does (its present in the sources) in reverse.
But be aware that unity is not exactly layed out at the usage you do there but as monolithic app that goes up and down along the engine so you might find more or less complex problems you might not be able to work around. Normally when interacting with native stuff its done the other way round: unity is always alive and you overlay a view controller, pausing unity along that so it does not run during the overlay
Looks like this thread is a few months old, but I was wondering if you figured out how to clean up Unity properly.
I’m attempting something similar, trying to load/unload Unity within an Obj C ios app and it starts/exits fine until I try to restart, then crashes with what looks like a mono error in the console:
Assertion at critical-sections.c:61, condition `ret == 0’ not met
Dreamora posted about reversing mono module registration, however I can’t find any way to unregister these modules (as opposed to mono_aot_register_module). I’m assuming there must be a mono_aot_destroy_module or some similar function but have not found anything in the mono man page.
Has anyone successfully done this, or have any ideas?
I have the same error - situation is not changed.
I submited a bug one year ago - but no progress…
Maybe someone unity developer could comment?
PLEASE! HELP!
How to restart unity completly under iOS - I need to use several Unity projects in one iOS application.
I need shutdown - but got the same as above assertion in critical section!!!
I spent a good while digging to try and do this same thing and I do not believe it is possible. The UnityCleanup function calls into the compiled Unity closed source Unity library to do its work, and it does so in a way that does not reset up unity to be called and started again.
The only feasible way I think you could get this to work is to do something extremely hackey like watch all the memory that UnityStart registers, then on cleanup clear that memory explicitly, not relying on UnityCleanup(). But the possibilities of that working smoothly and reliably are not something I’d bank on for any serious work.
It seems this post is too old and no solution for this issue.
I need to stop Unity and get back memory from unity and then continue to native app.
Can anyone help?
I called it unloadapplication in a native app, but the memory is still high, how can I reduce the system.excutableanddlls.and
the API "unloadapplication"in unity document show it will reduce large memory and residue 110mb memory, how to do this