using System.Collections;
using System.Collections.Generic;
using UnityEditor.SceneManagement;
using UnityEditor;
using UnityEngine;
namespace ZExtensions
{
/// <summary>
/// 编辑器运行时固定启动场景
/// </summary>
public class PlayModeUseDefaultScene
{
[UnityEditor.MenuItem("BuildTools/PlayModeUseFirstScene")]
static void UpdatePlayModeUseFirstScene()
{
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
if (scenes.Length > 0)
{
SceneAsset firstScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(scenes[0].path);
if (firstScene != null)
{
EditorSceneManager.playModeStartScene = firstScene;
Debug.Log("Play mode start scene set to: " + firstScene.name);
}
else
{
Debug.LogError("Failed to load the first scene from the build settings.");
}
}
else
{
Debug.LogError("No scenes found in the build settings.");
}
}
}
}
文章评论