Beispiel #1
0
    void OnApplicationQuit()
    {
        MVRNodesCreator.DestroyInstance();
        MVRNodesMapper.DestroyInstance();

        MVRTools.VRDestroy(Application.isEditor);
    }
Beispiel #2
0
    protected void Awake()
    {
        MVRNodesMapper.CreateInstance();
        MVRNodesCreator.CreateInstance();

        InitializeVR();
    }
    protected void Awake()
    {
        // Attempt to collect objects from previous level
        System.GC.Collect();
        System.GC.WaitForPendingFinalizers();
        // Second call to work around a possible mono bug (see https://bugzilla.xamarin.com/show_bug.cgi?id=20503 )
        System.GC.WaitForPendingFinalizers();

        MVRNodesMapper.CreateInstance();
        MVRNodesCreator.CreateInstance();

        InitializeVR();
    }
    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
    }