Autorun

From Unify Community Wiki
Revision as of 17:53, 1 October 2011 by Matt maker (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<csharp> 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

/// /// 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.

   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox