代碼如下:
- 先打開目標場景:EditorSceneManager.OpenScene
- Play:EditorApplication.isPlaying = true
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
public class Tools
{
[MenuItem("Tools/從Start場景開始Play")]
private static void PlayStartScene()
{
EditorSceneManager.OpenScene("Assets/Scenes/Start.unity");
EditorApplication.isPlaying = true;
}
}