You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.2 KiB
25 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
public static class ContextMenu {
|
|
[MenuItem("GameObject/UI/Custom/Button", false, 12)]
|
|
public static void PlaceButton(MenuCommand menuCommand) => PlaceCustomUI("Button", menuCommand);
|
|
|
|
[MenuItem("GameObject/UI/Custom/Input", false, 12)]
|
|
public static void PlaceInput(MenuCommand menuCommand) => PlaceCustomUI("Input", menuCommand);
|
|
|
|
[MenuItem("GameObject/UI/Custom/Scrollable", false, 12)]
|
|
public static void PlaceScrollable(MenuCommand menuCommand) => PlaceCustomUI("Scrollable", menuCommand);
|
|
|
|
[MenuItem("GameObject/UI/Custom/Container", false, 12)]
|
|
public static void PlaceContainer(MenuCommand menuCommand) => PlaceCustomUI("Container", menuCommand);
|
|
|
|
public static void PlaceCustomUI(string part, MenuCommand mc) {
|
|
var go = GameObject.Instantiate(Resources.Load("CustomUI/" + part), Vector3.zero, Quaternion.identity) as GameObject;
|
|
go.name = part;
|
|
GameObjectUtility.SetParentAndAlign(go, mc.context as GameObject);
|
|
Undo.RegisterCreatedObjectUndo(go, "Create Custom " + part);
|
|
Selection.activeObject = go;
|
|
}
|
|
}
|
|
|