Possible to execute a script before Editor close?

Hi, I need to call a script just before the UnityEditor shuts down (File/Exit or ). Is it possible?

Thx, chi

if you have a editor window you can make use of OnDestory. if it is a script that should run on exit, I am not sure. May be you can try overriding the normal exit functionality with your own menu command.

3 Answers

3

try this link

Thank you! But OnApplicationQuit() doesn’t work for me… I need to call an editor script (setting the EditorFrefs) when the user decides to close the UnityEditor completely… Something like [InitializeOnLoad] just the other way around :wink:

In general you create a .exe or something and users don't use Unity3D to run your application. So how does your application work?

@thef1chesser, he is asking about Editor script that does something smiliar to OnApplicationQuit() function.

I´m working on a editor extension that needs to be set (from a script) to "MonoDevelop (build-in)" under Preferences/External Tools/External Script Editor if its Unity <= 4.2 or to "My Program" if Unity >= 4.3 was detected. What I´m trying to achieve is to set "My Program" as the default external script editor every time I close Unity!

SImilar problem

OnApplicationQuit()