- Home /
Unity Editor: Button to restart unity.
Hi people. I have a little problem with my installed version of unity 3.5.7, it sometimes just stops working and freezes a lot. The problem is caused because ( I think ) have a lot of plugins installed in my project.
I have to keep saving the project several times in order to keep my project safe from this crashes. The thing is that if unity freezes, I have to use the Force Quit window of osx to reopen unity again, and when I quit unity in this way, the project is not completely saved. If I reopen the project, the changes I had before the crash are lost, its like the save project button in the menu were not really saving the project, but waiting until unity closes itself that the project changes are commited.
In order to fix this I decided to restart unity each time I save ( its not frustrating since a Solid State Drive does well the job loading everything ), so I do the following:
Save scene
Save project
close unity
open unity
I already know how to save a scene ( and save a project too, I think -_- ) in code.
The question is: Is it posible to code that unity close itself and reopens itself again. Like firefox when you restart it; and put all this steps together to create my custom "Save" button.
Thanks.
i don't remember the exact code but i had a similar case where i wanted to copy the whole project to a new folder then open it and close the current project.
First of all,i did save the scene and project by code. Then you can call Unity.exe and pass the folder of project as argument again by code. Then in the next line close the current unity process.
That way you should be able to restart unity and keep your changes.
But better backup before trying.
Also refer to http://answers.unity3d.com/questions/16675/running-an-external-exe-file-from-unity.html this to call Unity.exe or if you are on windows platform you can try using windows api to call the Unity.exe which is what i did before.
Answer by DaveA · May 12, 2013 at 05:38 PM
I think you would want to launch an external program, probably .bat or other simple script, that opens unity.
http://answers.unity3d.com/questions/16675/running-an-external-exe-file-from-unity.html