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 ...