Hi. I have a script that calls Code (CSharp): XRDevice.GetNativePtr and passes the pointer to a custom native plugin subsystem. That same script uses Code (CSharp): OnApplicationQuit to shutdown the subsystem. Unfortunately OnApplicationQuit is getting called after the GetNativePtr is invalidated. So it seems like Unity is shutting down the XRPlugin before OnApplicationQuit. The end result is a crash in my native plugin. Is there a way to detect that the XRPlugin is about to be shutdown? Looking at the reference I see an event for when it is loaded. But not an event that fires just before it is unloaded. I'm using Unity 2019.4 and this is all using the Oculus plugin. Thanks!
What do you mean by Native Plugin Subsystem? Do you mean a standard Unity plugin or do you mean a full on Subsystem implementation? Either way, your best bet is to manually manage the lifetime of the loader yourself. This way you are in control of when it starts and stops and you know the actual lifetime you are working with. See: End-user documentation | XR Plugin Management | 3.2.17 (unity3d.com)