I want to instantiate a prefab within the context menu (Components). I got the code to create the entry in the context menu, but I can't figure out how to place my prefab in the scene. My current code is somehow like this :
using UnityEngine;
using UnityEditor;
using System.Collections;
public static class MenuItemGameobject {
[MenuItem("GameObject/Create RedBlue GameObject", false, 12)]
static void Init()
{
Debug.Log("here");
//new GameObject("RedBlue GameObject"); // This adds an empty GO
//new GameObject((GameObject.Find("UIPlane"))); //This duplicates the GO if it is already in the scene
//PrefabUtility.InstantiatePrefab(); //This is the method which I guess is needed, but I don't know how to get the GO parameter
}
}
So again, I want to add my prefab exactly like you add a cube within the context menu.
Edit : This is how a public variable looks like in the inspector :
