Skip to content

Instantly share code, notes, and snippets.

@json-m
Created September 9, 2024 18:59
Show Gist options
  • Select an option

  • Save json-m/4b8e7411ecaa0770e87cd815a3b4246d to your computer and use it in GitHub Desktop.

Select an option

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
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