Created
February 13, 2019 05:46
-
-
Save kankikuchi/e9c760b3185a3dee19beb3a73bc0be8f to your computer and use it in GitHub Desktop.
Scenes in Buildの一番上に登録されているシーンから再生を開始するメニュー【Unity】
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
// PlayFromFirstSceneTool.cs | |
// http://kan-kikuchi.hatenablog.com/entry/EditorTool | |
// | |
// Created by kan.kikuchi on 2019.02.13. | |
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.EditorTools; | |
/// <summary> | |
/// Scenes in Buildの一番上に登録されているシーンから再生を開始するメニュー | |
/// </summary> | |
[EditorTool("Play From First Scene Tool")] | |
class PlayFromFirstSceneTool : EditorTool { | |
//アイコンの画像 | |
[SerializeField] | |
private Texture2D _toolIcon = null; | |
//アイコンの画像や説明などGUI要素を設定するもの | |
private GUIContent _content = null; | |
//GUI要素を取得する用のプロパティ | |
public override GUIContent toolbarIcon { | |
get { return _content; } | |
} | |
//================================================================================= | |
//初期化 | |
//================================================================================= | |
private void OnEnable() { | |
//GUIの要素を作成 | |
_content = new GUIContent() { | |
image = _toolIcon, //アイコンの画像 | |
text = "Play From First Scene Tool", //メニューの名前 | |
tooltip = "Scenes in Buildの最初のシーンから再生開始" //メニューの説明 | |
}; | |
} | |
//================================================================================= | |
//状態変更 | |
//================================================================================= | |
/// <summary> | |
/// このツールが選択された時に実行される | |
/// </summary> | |
public override void OnActivate() { | |
EditorPlayer.PlayFromFirstScene(); | |
} | |
//================================================================================= | |
//更新 | |
//================================================================================= | |
/// <summary> | |
/// このツールを選択中に呼ばれ続けるメソッド(Sceneビューを開いてないと呼ばれない) | |
/// </summary> | |
public override void OnToolGUI(EditorWindow window) { | |
//前選択していたツールに戻す | |
EditorTools.RestorePreviousTool(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment