Question by
daveX_ · Feb 17, 2019 at 02:21 AM ·
gameobjectparentchildmenuitem
How to set GameObject created by MenuItem as a child of Canvas
Hi i need help how can i set the gameobject created by menuitem as a child of canvas
[MenuItem("GameObject/UI/Custom Button", false, 10)]
static void CreateCustomButton(MenuCommand menuCommand)
{
GameObject custombutton =
(GameObject)PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<Object>
("Assets/Prefabs/CustomButton.prefab"));
Undo.RegisterCreatedObjectUndo(custombutton, "Create " + custombutton.name);
Selection.activeObject = custombutton;
}
Comment