Hi, I’ve been messing around the unity editor and was wondering if there is any possibility to create a new button or folder on the ‘Assets → Create’ menu, I’m aiming on making quick instantiable prefabs, let’s say I have a ‘sword’ asset prefab and I want to quickly instantiate one from that menu…
You can use this Unity - Scripting API: ScriptableWizard
But I don’t think it’s gonna be fun making prefabs like that, I just do prefabs in the scene real quick, if i need a quiet place just go up by like a 1000 units.
Hm I see how that would work, but I’m aiming for something like a simple solution, my prefabs has only one script attached into them, but it stills boring to create a gameobject and attach the component to it, or to create a prefab and always unpack the prefab to make different choices on the component
Isn’t there any way to create a ‘CreateMenuAsset’ to create a empty object with the component already attached into it? Such as creating a light, it’s a empty object with the light component.
“Isn’t there any way to create a ‘CreateMenuAsset’ to create a empty object with the component already attached into it? Such as creating a light, it’s a empty object with the light component.”
You mean something like this?
public class CreateObjTest : MonoBehaviour
{
[MenuItem("GameObject/Stuff/Custom Obj", false, 10)]
static void CreateCustomObj()
{
var go = new GameObject("foo");
go.AddComponent<Rigidbody>();
go.AddComponent<BoxCollider>();
}
}
The sample code in the MenuItem documentation. constains several examples. One that extends the “GameObject” menu and above that there’s an example how to extend the context menu of an arbitrary component.