Menu Shortcuts and Additional Styling

Geprüft mit Version: 2017.3


Schwierigkeitsgrad: Fortgeschrittene Anfänger

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

Fortgeschrittene Anfänger 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;


Ähnliche Tutorials