- Home /
Enter play mode from editor script after baking is complete
Hello,
We have an application we are developing where we like to enter play mode from an editor script once the scene is opened. I have created an editor script that is contained in the folder Assets/Editor directory that does the following:
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class MyEditorScriptExisting
{
static MyEditorScriptExisting()
{
EditorApplication.ExecuteMenuItem("Edit/Play");
}
}
It is successfully called and ran, however we get this error when trying to run the function ExecuteMenuItem:
ExecuteMenuItem failed because there is no menu named 'Edit/Play'
UnityEditor.EditorApplication:ExecuteMenuItem(String)
Is there anyway around this, or is there something we are doing incorrectly? We'd like to run the application on startup and also like for it to wait until the baking is complete before entering play mode. I followed this thread here Start/Stop Playmode from editor script which helped in getting a script to execute in edit mode, but whenever I try and run the ExecuteMenuItem function it throws this error. Any help would be greatly appreciated.
Thanks!
Your answer
Follow this Question
Related Questions
How to keep Unity Editor TCP client and Tcp Server static variables when entering PlayMode 0 Answers
Add/Remove scene to build settings from editor script and run levels in editor 0 Answers
DestroyImmediate(component.gameObject) destroys component but not gameObject 1 Answer
Custom editor script for folders? 1 Answer
Render overlay in editor like the NavMesh Display option 'Show NavMesh' 0 Answers