Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorBuildSettings.scenes

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

マニュアルに切り替える
public static var scenes: EditorBuildSettingsScene[];
public static EditorBuildSettingsScene[] scenes;

Description

ビルドに加えたいシーンのリスト。 これは、ビルド設定 ウィンドウに表示されるシーンのリストと同じものです。このリストを修正して、ビルドにどのシーンを加えるかを設定できます。

#pragma strict
import System.Collections.Generic;

//C# Example public class ExampleWindow extends EditorWindow { var m_SceneAssets: List.<SceneAsset> = new List.<SceneAsset>(); // Add menu item named "Example Window" to the Window menu @MenuItem("Window/Example Window") public static function ShowWindow() { //Show existing window instance. If one doesn't exist, make one. EditorWindow.GetWindow(ExampleWindow); } function OnGUI() { GUILayout.Label("Scenes to include in build:", EditorStyles.boldLabel); for (var i: int = 0; i < m_SceneAssets.Count; ++i) { m_SceneAssets[i] = EditorGUILayout.ObjectField(m_SceneAssets[i], SceneAsset, false) as SceneAsset; } if (GUILayout.Button("Add")) { m_SceneAssets.Add(null); } GUILayout.Space(8); if (GUILayout.Button("Apply To Build Settings")) { SetEditorBuildSettingsScenes(); } } public function SetEditorBuildSettingsScenes() { // Find valid scene paths and make a list of EditorBuildSettingsScene var editorBuildSettingsScenes: List.<EditorBuildSettingsScene> = new List.<EditorBuildSettingsScene>(); for (var sceneAsset: SceneAsset in m_SceneAssets) { var scenePath: String = AssetDatabase.GetAssetPath(sceneAsset); if (!String.IsNullOrEmpty(scenePath)) editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(scenePath, true)); } // Set the build settings window scene list EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray(); } }
//C# Example

using System.Collections.Generic; using UnityEditor; using UnityEngine;

public class ExampleWindow : EditorWindow { List<SceneAsset> m_SceneAssets = new List<SceneAsset>();

// Add menu item named "Example Window" to the Window menu [MenuItem("Window/Example Window")] public static void ShowWindow() { //Show existing window instance. If one doesn't exist, make one. EditorWindow.GetWindow (typeof(ExampleWindow)); }

void OnGUI() { GUILayout.Label("Scenes to include in build:", EditorStyles.boldLabel); for (int i=0; i<m_SceneAssets.Count; ++i) { m_SceneAssets[i] = (SceneAsset)EditorGUILayout.ObjectField (m_SceneAssets[i], typeof(SceneAsset), false); } if (GUILayout.Button ("Add")) { m_SceneAssets.Add (null); }

GUILayout.Space (8);

if (GUILayout.Button("Apply To Build Settings")) { SetEditorBuildSettingsScenes (); } }

public void SetEditorBuildSettingsScenes () { // Find valid scene paths and make a list of EditorBuildSettingsScene List<EditorBuildSettingsScene> editorBuildSettingsScenes = new List<EditorBuildSettingsScene>(); foreach (var sceneAsset in m_SceneAssets) { string scenePath = AssetDatabase.GetAssetPath (sceneAsset); if (!string.IsNullOrEmpty (scenePath)) editorBuildSettingsScenes.Add (new EditorBuildSettingsScene (scenePath, true)); }

// Set the build settings window scene list EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray (); } }