Skip to Content
Mastering UI Development with Unity
book

Mastering UI Development with Unity

by Dr. Ashley Godbold
April 2018
Beginner content levelBeginner
468 pages
11h 7m
English
Packt Publishing
Content preview from Mastering UI Development with Unity

UI variable types

Each variable type is a class within the UnityEngine.UI namespace. Therefore, each of these variable types, in turn, have their own set of variables and functions that can be accessed. We'll discuss each variable type more thoroughly in the future sections and chapters, but, for now, let's just look at the standard template for accessing a property of a UI element in code.

In the Chapter4Text scene available in the provided project, you will see a UI Image named UI Variables Example. It does not have a sprite assigned to it and appears as a white square. The following script, AddSprite.cs, is attached to the UI Image:

using System.Collections;using System.Collections.Generic;using UnityEngine;using  UnityEngine.UI;public ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Game Development with Unity for .NET Developers

Game Development with Unity for .NET Developers

Jiadong Chen
Unity UI Cookbook

Unity UI Cookbook

Francesco Sapio

Publisher Resources

ISBN: 9781787125520Supplemental Content