Autorun

From Unify Community Wiki
Jump to: navigation, search

Save this script as Autorun.cs in your Editor folder:

using UnityEngine;
using UnityEditor;
// from the excellent http://answers.unity3d.com/questions/45186/can-i-auto-run-a-script-when-editor-launches-or-a.html
 
///
/// This must be added to "Editor" folder: http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html
/// Execute some code exactly once, whenever the project is opened, recompiled, or run.
///
[InitializeOnLoad]
public class Autorun
{
    static Autorun()
    {
        EditorApplication.update += RunOnce;
    }
 
    static void RunOnce()
    {
        Debug.Log("RunOnce!");
        EditorApplication.update -= RunOnce;
 
		// do something here. You could open an EditorWindow, for example.
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox