April 2017
Beginner to intermediate
376 pages
8h 4m
English
We are not limited to the Unity UI to make interfaces in Unity, and to prove that point, we will use the ball object itself to affect the scene. While we have seen this in the past, this lesson is worth repeating:
Here is the code for that script file; either type it out or copy and paste it and name the file PowerSwitch.cs:
using UnityEngine;
using System.Collections;
public class PowerSwitch : MonoBehaviour {
public GameObject go;
void OnSelect()
{
if(go.activeSelf)
{
go.SetActive(false);
}
else
{
go.SetActive(true);
}
}
}
This code uses a single public ...
Read now
Unlock full access