Menu Shortcuts and Additional Styling

확인 완료한 버전: 2017.3


난이도: 중급

In this session Online Evangelist Matt Gambell will take us through building a system that allows for a flexible and customisable way to work with UI in a project by taking advantage of the power of ScriptableObjects.

Menu Shortcuts and Additional Styling

중급 User Interface (UI)


Code snippet

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class FlexibleUIInstance : Editor {

    [MenuItem("GameObject/Flexible UI/Button", priority = 0)]
    public static void AddButton()

    static GameObject clickedObject;

    private static GameObject Create(string objectName)
        GameObject instance = Instantiate(Resources.Load<GameObject>(objectName)); = objectName;
        clickedObject = UnityEditor.Selection.activeObject as GameObject;
        if (clickedObject != null)
                instance.transform.SetParent(clickedObject.transform, false);
        return instance;


관련 자습서