- Home /
(Editor Scripting) Is There A Way To Mimic The "Add Component" Menu??
Hi, is there a way to make a dropdown menu that contains a list of components like the "Add Component" menu?
Happy holidays!
Don't think there is a ready solution for this but it is easy to break it down to simple GUI elements. First the Add Component is a button can be created with GUI.Button(), then you need to create an Area that will render on top of everything else, on top of it the Search Bar would be a string field can be found in GUI, GUILayout and EditorGUILayout *.StringField) below is a Label of selected category , afterwards there are the choices, first you need a way to pick all Objects you want to show and seperate them on categories, now each element is either a Category element thus clicking it brings relevant options or an actual component that if clicked is added to current GameObject, to replicate this if there is not a ready solutions (no clue if there is) or again you ll have to combine simple GUI elements. Anyway if you are not accustomed with the gui API/ editor scripting, I would recommend to follow some tutorials first.
Anyway if you have less options you could just skip all that and use the Generic$$anonymous$$enu class. Cheers.
Answer by SpiralConDave · Jan 19, 2018 at 01:09 AM
You can find the decompiled Editor source on github and try to find how They did it.
Your answer

Follow this Question
Related Questions
Save Components setting for reuse 1 Answer
Drop down menu in Custom Editor 4 Answers
Show a dropdown for C# classes in inspector. 2 Answers
How do you edit default components? 1 Answer
Find all components in project 1 Answer