UnityDoorstop
UnityDoorstop copied to clipboard
Doorstop does not initialize when game process spawns itself/restarts itself
I have worked on a BepInEx plugin that automatically updates itself, and user is given a restart prompt. When you call Process.Start on the running game, it will inherit the environment variables from the running process for the newly spawned process, causing Doorstop to not initalize properly in the new process.
(i know #34 exists)
I have found a workaround for anyone else that has this issue
var startInfo = new ProcessStartInfo();
startInfo.FileName = Paths.ExecutablePath;
startInfo.WorkingDirectory = Paths.GameRootPath;
startInfo.UseShellExecute = false;
// remove environment variables that new process will inherit
startInfo.Environment.Remove("DOORSTOP_INITIALIZED");
startInfo.Environment.Remove("DOORSTOP_DISABLE");
Process.Start(startInfo);
Application.Quit();