Skip to content

Instantly share code, notes, and snippets.

@teach310
Created July 1, 2016 05:17
Show Gist options
  • Save teach310/aa53fccc4531d424ea02eee5a2f94caa to your computer and use it in GitHub Desktop.
Save teach310/aa53fccc4531d424ea02eee5a2f94caa to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour {
int currentState = 0; // 0: Blue 1: Red
void Update () {
// state: Blue
if (currentState == 0) {
Debug.Log ("Blue");
// 状態変更
if (Input.GetKeyDown (KeyCode.R)) {
currentState = 1;
}
}
// state: Red
if (currentState == 1) {
Debug.Log ("Red");
if(Input.GetKeyDown(KeyCode.B)){
currentState = 0;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment