Skip to content

Instantly share code, notes, and snippets.

@nrichards
Last active June 12, 2023 19:58
Show Gist options
  • Save nrichards/2bc4a51f79d688fa4b82bbfae217c7ed to your computer and use it in GitHub Desktop.
Save nrichards/2bc4a51f79d688fa4b82bbfae217c7ed to your computer and use it in GitHub Desktop.
Unity: MonKey Commander: Custom command code-chunk to find Component by name in your Project
/// This is the magic, added to SelectionUtilities.cs function SelectOfType,
/// replacing the similar code, at the end of the function.
EditorUtility.ClearProgressBar();
if (Selection.objects.Length > 0) {
SetSelectionActiveVersionIndependent(Selection.objects[0]);
var components = ((GameObject)Selection.objects[0]).GetComponents(type);
foreach (var c in components) {
var niceName = ObjectNames.NicifyVariableName(c.GetType().Name);
EditorApplication.delayCall += () => {
EditorApplication.delayCall += () => {
Highlighter.Highlight("Inspector", niceName);
};
};
}
}
else
{
Debug.Log("MonKey found no objects of the corresponding type");
}
@nrichards
Copy link
Author

📺 Video demo: https://youtu.be/RnSxForUd_A 🥳

Flaws:

  • only highlights the 1st matching Component of the 1st selected GameObject when multiple game objects are found - is this bad?
  • highlight does not stop "pulsing" - how to Highlight.Stop() after X seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment