Created
September 9, 2024 18:59
-
-
Save json-m/4b8e7411ecaa0770e87cd815a3b4246d to your computer and use it in GitHub Desktop.
automatically selects GestureManager in Unity when entering playmode, add to any Editor/ folder
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 UnityEngine; | |
| using UnityEditor; | |
| [InitializeOnLoad] | |
| public class AutoSelectGestureManager | |
| { | |
| static AutoSelectGestureManager() | |
| { | |
| EditorApplication.playModeStateChanged += OnPlayModeStateChanged; | |
| } | |
| private static void OnPlayModeStateChanged(PlayModeStateChange state) | |
| { | |
| if (state == PlayModeStateChange.EnteredPlayMode) | |
| { | |
| GameObject gestureManager = GameObject.Find("GestureManager"); | |
| if (gestureManager != null) | |
| { | |
| Selection.activeGameObject = gestureManager; | |
| } | |
| else | |
| { | |
| Debug.LogWarning("GestureManager not found in the scene."); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment