Created
December 8, 2013 11:08
-
-
Save baba-s/7855970 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using UnityEditor; | |
using UnityEngine; | |
/// <summary> | |
/// シーンを開く拡張ウィンドウ | |
/// </summary> | |
public class OpenScene : EditorWindow | |
{ | |
private Vector2 _scrollPos; // スクロールの座標 | |
/// <summary> | |
/// シーンを開く拡張ウィンドウを開く | |
/// </summary> | |
[MenuItem("Tools/Open Scene")] | |
public static void Init() | |
{ | |
GetWindow<OpenScene>("Open Scene"); | |
} | |
/// <summary> | |
/// シーンを開く拡張ウィンドウを表示する | |
/// </summary> | |
private void OnGUI() | |
{ | |
EditorGUILayout.BeginVertical(); | |
// スクロール可能なビューを作成する | |
_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Height(position.height)); | |
// シーンファイルのパスを取得する | |
var paths = (from scene in EditorBuildSettings.scenes | |
select scene.path).Distinct(); | |
// シーンファイルを読み込むボタンを作成する | |
foreach (var path in paths) | |
{ | |
if (GUILayout.Button(path)) | |
{ | |
if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) | |
{ | |
EditorApplication.OpenScene(path); | |
} | |
} | |
} | |
EditorGUILayout.EndScrollView(); | |
EditorGUILayout.EndVertical(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment