- 教程
- User Interface (UI)
- Creating a Button
Creating a Button
版本检查: 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.


Creating a Button
中级 User Interface (UI)
FlexibleUIButton
Code snippet
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Image))]
[RequireComponent(typeof(Button))]
public class FlexibleUIButton : FlexibleUI
{
Button button;
Image image;
public ButtonType buttonType;
protected override void OnSkinUI()
{
base.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;
}
相关教程
- Introduction (课程)
- Building a Framework (课程)