- Home /
Script that runs myUpdate all the time during Editor?
I know editor script allows us to use its functionality to hook up our own GUI functions and the ones which can run along with the Unity's viewport update.
However, due to the nature of the Editor script, we specify when it should kick in, for example, [CustomEditor(typeof(GameObject))] will make the editor script to work only if the gameObject is selected.
Is there a way to make it work even if the gameObject/script is not selected? Perhaps a static class / singleton coroutine will work?
Thank you
Answer by GameVortex · Oct 29, 2014 at 07:12 AM
My preferred method is hooking a function to the update event in EditorApplication. This update will then run about 100 times a second, and do not require anything to be selected.
See the bottom example in the manual on running code on startup: http://docs.unity3d.com/Manual/RunningEditorCodeOnLaunch.html
Answer by Kiwasi · Oct 29, 2014 at 07:02 AM
[ExecuteInEditMode]
http://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html
meh, don't want to have an object in the scene. Was hoping to get some sort of static class or singleton to avoid it. Tried them but it's not working out
Your answer
![](https://koobas.hobune.stream/wayback/20220613170231im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity 2020.2 crashes when loading my Unity 2020.1 project 0 Answers
Memory Leak Adventures in Editor (3.4, lot of instantiated objects) 1 Answer
Update Preference Item when Preference menu is closed 1 Answer
Not updating when script value is changed by an editor script 1 Answer
EditorApplication.update way more frequent than 100 times per second? 1 Answer