Exemplo n.º 1
0
        void OnGUI()
        {
            EditorLayoutTools.SetLabelWidth(120f);

            EditorGUILayout.Separator();

            using (new EditorGUILayout.HorizontalScope())
            {
                var sceneName = Path.GetFileName(targetScenePath);

                if (EditorLayoutTools.DrawPrefixButton("Scene", GUILayout.Width(65f)))
                {
                    SceneSelectorPrefs.selectedScenePath = targetScenePath;
                    SceneSelector.Open().Subscribe(OnSelectScene);
                }

                var sceneNameStyle = GUI.skin.GetStyle("TextArea");
                sceneNameStyle.alignment = TextAnchor.MiddleLeft;

                EditorGUILayout.SelectableLabel(sceneName, sceneNameStyle, GUILayout.Height(18f));

                GUILayout.Space(5f);
            }

            GUILayout.Space(5f);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(5f);

                // 下記条件時は再生ボタンを非アクティブ:.
                // ・実行中.
                // ・ビルド中.
                // ・遷移先シーンが未選択.
                GUI.enabled = !(EditorApplication.isPlaying ||
                                EditorApplication.isCompiling ||
                                string.IsNullOrEmpty(targetScenePath));

                if (GUILayout.Button("Launch"))
                {
                    Launch().Subscribe();
                }

                GUI.enabled = true;

                GUILayout.Space(5f);
            }
        }
Exemplo n.º 2
0
        void OnGUI()
        {
            EditorLayoutTools.SetLabelWidth(120f);

            EditorGUILayout.Separator();

            using (new EditorGUILayout.HorizontalScope())
            {
                if (EditorLayoutTools.PrefixButton("Scene", GUILayout.Width(65f), GUILayout.Height(18f)))
                {
                    SceneSelector.Prefs.selectedScenePath = sceneAsset != null?AssetDatabase.GetAssetPath(sceneAsset) : null;

                    SceneSelector.Open().Subscribe(OnSelectScene);
                }

                if (sceneNameStyle == null)
                {
                    sceneNameStyle           = EditorStyles.textArea;
                    sceneNameStyle.alignment = TextAnchor.MiddleLeft;
                }

                using (new EditorGUILayout.VerticalScope())
                {
                    GUILayout.Space(3f);

                    EditorGUI.BeginChangeCheck();

                    sceneAsset = EditorLayoutTools.ObjectField(sceneAsset, false);

                    if (EditorGUI.EndChangeCheck())
                    {
                        Prefs.targetSceneGuid = UnityEditorUtility.GetAssetGUID(sceneAsset);
                    }
                }

                GUILayout.Space(5f);
            }

            GUILayout.Space(5f);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(5f);

                // 下記条件時は再生ボタンを非アクティブ:.
                // ・実行中.
                // ・ビルド中.
                // ・遷移先シーンが未選択.
                var disable = EditorApplication.isPlaying || EditorApplication.isCompiling || sceneAsset == null;

                using (new DisableScope(disable))
                {
                    if (GUILayout.Button("Launch"))
                    {
                        Launch().Subscribe();
                    }
                }

                GUILayout.Space(5f);
            }
        }