How to restart application

I’d like to restart the whole game, not loading another level.
I would think that launching a new instance on a new thread, and then terminating the current thread would be a cheap restart function, but from what I hear, unity is single threaded.

Ideas?

Good solution @tanoshimi.
I found a solution on my own before reading your post, so here is my results for those also looking to do the same as me.

System.Diagnostics.Process.Start(Application.dataPath.Replace("_Data", ".exe")); //new program Application.Quit(); //kill current process

The magic words to restart your app. Best placed in a void or something and called when you need to restart. Make sure you have access to the directory and execute permissions, or you’ll get an AccessDenied exception or something.

Hello!

Unity does not give us API to restart app, so it looks like there are no way to do this.
Yes, Unity is single-threaded and messing with threads in Unity is bad idea.

Do you really need to restart app? Why not create additional loader scene and make all initialization there?

P.S. Sorry for my English.

I don’t quite understand why you’d want to do this rather than simply reload the first scene - launching a whole new instance of the game is going to cause all the resources in memory to be unloaded and reloaded again, for example. But have you tried something like:

Process.Start(Application.dataPath + "/../YourGameName.exe"); 
Application.Quit();

This is the only way I possibly know to restart the app…

What it does is it searches the executable directory, for the executable, and runs it.

The main weakness is that anyone who puts random exe’s in their game directory is in for some roulette >:)

public static void restart() {
	string[] endings = new string[]{
		"exe", "x86", "x86_64", "app"
	};

	string executablePath = Application.dataPath + "/..";
	foreach (string file in System.IO.Directory.GetFiles(executablePath)) {

		foreach (string ending in endings) {
			if (file.ToLower ().EndsWith ("." + ending)) {
				System.Diagnostics.Process.Start (executablePath + file);
				Application.Quit ();
				return;
			}
		}
			
	}
}

EDIT: This can handle renaming the executable, so it is perfect for general use.