Game Development Reference
In-Depth Information
The last thing you will need is a way to interface with the START! button. Create
one final script called StartButtonController and code it as shown in the
following script:
using UnityEngine;
using System.Collections;
public class StartButtonController : MonoBehaviour
{
public GameObject upSprite;
public GameObject downSprite;
public float downTime = 0.1f;
public GameStates stateManager = null;
private enum buttonStates
{
up = 0,
down
}
private buttonStates currentState = buttonStates.up;
private float nextStateTime = 0.0f;
void Start()
{
upSprite.SetActive(true);
downSprite.SetActive(false);
}
void OnMouseDown()
{
if(nextStateTime == 0.0f && currentState ==
StartButtonController.buttonStates.up)
{
nextStateTime = Time.time + downTime;
upSprite.SetActive(false);
downSprite.SetActive(true);
currentState = StartButtonController.buttonStates.down;
}
}
void Update()
 
Search WWH ::




Custom Search