Is there a way to programatically start the play mode in the Unity editor in an editor script?
To launch from a menu item you would
[MenuItem("Play/PlayMe")]
public static void BuildAssetBundles()
{
EditorApplication.isPlaying = true;
EditorApplication.NewScene();
GameObject go = new GameObject("PlayMode");
go.AddComponent<PlaySomeMonoBehaviour>().WhatToDo =
PlaySomeMonoBehaviour.PlayMe;
}
In the PlaySomeMonoBehaviour class
public const string PlayMe = "PlayMe";
public class PlaySomeMonoBehaviour : MonoBehaviour {
public string WhatToDo = PlayMe;
void Start() {
switch (WhatToDo)
{
case PlayMe:
StartCoroutine((YetSomeOtherClass.DoSomething()));
break;
}
}
YetSomeOtherClass is just another MonoBehaviour manipulating GameObjects.
Yes dropping it here for anyone for an alternative that is awesome.
http://wiki.unity3d.com/index.php/SceneAutoLoader