- Home /
GenericMenu and ContextMenu question
i have a script that allows me to create an empty .txt in my assets for writing notes and the like, and i was wondering if there was a way to add my create function to the context menu within the project pane. i kno genericmenu is supposed to add custom drop downs but the example says for custom windows. and contextmenu only adds to objects with the script assigned to them.
is there a way to accomplish this? i can keep using my menuItem at the top, but id rather have it listed with all the other choices within the context menu.
Answer by troien · Nov 05, 2014 at 11:48 AM
You can do that by adding it to the Assets/Create menu item. Since the project view uses the same dropdown.
Also:
ContextMenu is used for a contextmenu in the inspector of your component
MenuItem is used for a contextmenu anywere else (Note that this needs to be placed in a script inside the Editor folder)
using UnityEngine; using UnityEditor;
public class EditorExample { [MenuItem("Assets/Create/YourNameHere")] static void YourMethod() { // Your code here } }
ya, i had actually found that out shortly after i postd my question, but it hadnt been approved yet so i couldnt take it down. but now others can find the answer
Your answer
![](https://koobas.hobune.stream/wayback/20220613170726im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Permanent handles (when object is not selected) 1 Answer
Check if a script is running in editor or game 2 Answers
Determining which Asset is connected to a GameObject. 3 Answers
Why does Assembly-CSharp reference UnityEditor.dll 0 Answers