Building a Framework

Checked with version: 2017.3

-

Difficulty: Intermediate

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.

Building a Framework

Intermediate User Interface (UI)

FlexibleUIData

Code snippet

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

[CreateAssetMenu(menuName = "Flexible UI Data")]
public class FlexibleUIData : ScriptableObject
{
    
}

FlexibleUI

Code snippet

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

public class FlexibleUI : MonoBehaviour {

    public FlexibleUIData skinData;

    protected virtual void OnSkinUI()
    {

    }

    public virtual void Awake()
    {
        OnSkinUI();
    }

    public virtual void Update()
    {
        if(Application.isEditor)
        {
            OnSkinUI();
        }
    }

}

Related tutorials