How do I add my script to the "Assets/Create" menu?
Hey, I want to add my script (an Item-script with name, ID and image) to the menu at "Assets/Create". I can display it when I right-click, but I want to know, how to add a new instance of this class to the files when I click on it, just like you do with materials and C# scripts. How do I do this?
The script looks like this:
using UnityEngine;
using System.Collections;
using UnityEditor;
public class Item {
public Sprite itemImage;
public string itemName;
public string itemID;
public Item(Sprite image,string name, string ID) {
itemImage = image;
itemName = name;
itemID = ID;
}
}
Answer by Jessespike · May 10, 2016 at 03:21 PM
Add a MenuItem. Your class won't work though, it needs to derive from MonoBehaviour.
Does it? I was not planning on addig it to GameObjects, I was planning to let an Inventory script handle that. BTW I now only have the option Item in the menu, but how do I make it addable like materials and scripts?
Answer by JonPQ · Mar 20, 2020 at 07:09 PM
read up on "CreateAssetMenu" and scriptable objects here... thats what you need. :0 https://docs.unity3d.com/Manual/class-ScriptableObject.html
Your answer
Follow this Question
Related Questions
Dropdown content out of bounds 1 Answer
Pause menu Change 0 Answers
Writing dropdown selections to file 1 Answer
Open Menu After Animation 1 Answer
How to use this menu (skins) in my game? 0 Answers