- Home /
EditorWindow start of application callback
Is there any way I can receive a callback in an EditorWindow script when the game starts playing? Because I want my extension to instantiate some prefabs right when the game starts. Since EditorWindow doesn't have Start() and Awake() callbacks, I'm doing it by instantiating the prefabs before the game starts, and then cleaning them up once EditorApplication.isPlaying goes to false. The problem with this is that if the window gets closed during the playback, the GameObjects will persist after the game ends. I don't want to check for EditorApplication.isPlaying in the Update function of my EditorWindow because that will give a slight delay (Time.time won't be zero when I find out that the game has started, and timing is crucial for my extension).
Answer by dbdenny · Dec 30, 2020 at 03:03 AM
[InitializedOnLoad]
public class OneClass
{
static OneClass
{
AddCleaningCallBackToApplicationRun();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613193447im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Debug.Log print order, or Awake vs Start issue? 1 Answer
TransformPoint - different results in Awake() and Start() 0 Answers
Awake/Start/Update order 1 Answer
Should I start instantiating my game objects in Start or Awake function when I load my scene? 1 Answer
Why not using Start exlusively in NetworkBehaviours? 0 Answers