Editor script that starts playMode and then does a thing after playMode starts.

This is in conjunction with another question, but different enough that I thought it deserved its own post.

Is there a way to make an editor script start playMode and then do a thing after playMode starts?

Right now I’ve got a script starting play mode:

[MenuItem("Assets/Test Me")]
static void TestPiece () {
	EditorApplication.SaveCurrentSceneIfUserWantsTo();
	EditorApplication.isPlaying = true;
	
	Debug.Log("DO A THING");
}

What I want to happen is:
1.GameMode starts.
2.Log - “DO A THING”.

What actually happens:
1.Log - “DO A THING”.
2. GameMode starts and all progress in 1 is lost.

Any ideas?

move “DO A THING” to start() on the other side of ur gamemode change would be your best bet.

guessing by the two questions you have up i think you may want to brush up on

I am 99% sure there is a more effective way of doing what you are trying to do.