void OnApplicationQuit() { MVRNodesCreator.DestroyInstance(); MVRNodesMapper.DestroyInstance(); MVRTools.VRDestroy(Application.isEditor); }
protected void OnApplicationQuit() { MVRNodesCreator.DestroyInstance(); MVRNodesMapper.DestroyInstance(); MiddleVR.DisposeObject(ref m_shareRandomStateCommand); MiddleVR.DisposeObject(ref m_startParticlesCommand); MVRTools.VRDestroy(Application.isEditor); // Unity 5.6 players crash on exit when any "-force-*" parameter is on the command line. // When launching from middlevr configuration, one of these parameters is always set, // so we kill the process as a workaround. // The environment variable MIDDLEVR_FORCE_KILL_PLAYER can be set to "false" (case insensitive) // to disable this behaviour. #if UNITY_5_6_OR_NEWER && !UNITY_EDITOR string[] crashingArguments = new string[] { "-force-d3d11", "-force-d3d9", "-force-opengl" }; bool commandLineHasCrashingArgument = Environment.GetCommandLineArgs().Any( commandLineArg => crashingArguments.Any( crashingArg => String.Equals(commandLineArg, crashingArg, StringComparison.OrdinalIgnoreCase))); if (commandLineHasCrashingArgument) { bool forceKill = true; string forceKillEnvVar = Environment.GetEnvironmentVariable("MIDDLEVR_FORCE_KILL_PLAYER"); if (forceKillEnvVar != null) { Boolean.TryParse(forceKillEnvVar, out forceKill); } if (forceKill) { System.Diagnostics.Process.GetCurrentProcess().Kill(); } } #endif }