- Home /
How to add items to the Component references context menu?
I would like to add a context menu item to call myComponent = gameObject.GetComponent<TComp>();
from the editor. Really helpful when prefabbing. I don't want to add a [ContextMenu] attribute to every single reference to a Component in my codebase, though.
I notice that OdinInspector has this behavior. Notice the image below how the context menu of the property PriorityParaLayer
has "Set to Null" and "Open in new inspector". I would like to add "GetComponent" to this menu.
Any thoughts on how to do this?
Thank you for your time.
Your answer
Follow this Question
Related Questions
Getting component variables in InitializeOnLoad editor script? 1 Answer
Adding to GameObject context menu WITHOUT [MenuItem(...)] 1 Answer
Creating Context Menu Item for FBX files 0 Answers
"2d object" missing in create context menu 2 Answers
EditorGUI add SortingLayer-like list to custom Editor 1 Answer