Skip to content

Instantly share code, notes, and snippets.

@Petethegoat
Created March 31, 2024 22:20
Show Gist options
  • Save Petethegoat/e1cb72fdc330f6ecbfacb5f5ebffde1f to your computer and use it in GitHub Desktop.
Save Petethegoat/e1cb72fdc330f6ecbfacb5f5ebffde1f to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
public static class SelectScript
{
[MenuItem("CONTEXT/Component/Select Script File")]
static void SelectScriptFile(MenuCommand command)
{
Selection.activeObject = AssetDatabase.LoadAssetAtPath<MonoScript>(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets(MonoScript.FromMonoBehaviour(command.context as MonoBehaviour).name)[0]));
//Does not handle non monobehaviour/monoscript components.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment