Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- [InitializeOnLoad]
- public class FocusOnPlayDummyWindow : EditorWindow {
- static FocusOnPlayDummyWindow _instance;
- static bool IsOpen { get { return _instance != null; } }
- [MenuItem("Window/Focus on Play Dummy Window")]
- static FocusOnPlayDummyWindow GetFocusOnPlayDummyWindow() {
- FocusOnPlayDummyWindow window = GetWindow<FocusOnPlayDummyWindow>("Dummy");
- window.Show();
- return window;
- }
- void OnEnable() {
- _instance = this;
- }
- void OnDisable() {
- _instance = null;
- }
- static FocusOnPlayDummyWindow() {
- EditorApplication.playModeStateChanged += OnPlayModeChanged;
- }
- static void OnPlayModeChanged(PlayModeStateChange playModeStateChange) {
- if (!IsOpen) { return; }
- switch (playModeStateChange) {
- case PlayModeStateChange.ExitingEditMode:
- GetFocusOnPlayDummyWindow().Focus();
- break;
- case PlayModeStateChange.EnteredEditMode:
- GetWindow<SceneView>().Focus();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement