Creating a Button

Revisado con versión: 2017.3


Dificultad: Intermedio

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.

Creating a Button

Intermedio User Interface (UI)


Code snippet

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FlexibleUIButton : FlexibleUI

    Button button;
    Image image;

    public ButtonType buttonType;

    protected override void OnSkinUI()

        image = GetComponent<Image>();
        button = GetComponent<Button>();

        button.transition = Selectable.Transition.SpriteSwap;
        button.targetGraphic = image;

        image.sprite = skinData.buttonSprite;
        image.type = Image.Type.Sliced;
        button.spriteState = skinData.buttonSpriteState;

Tutoriales relacionados