staticで変数をグローバル化しているけど,これは使用したのか不明.
lapTimeのboolをOn/Offしてて,ポーズ中は時間経過をスルー if(false) させている.
ポーズ中は色を点滅= コルーチンのcolorSwitch()のとこ
これ,colorSwitch()のコルーチンを止めていないっぽいんで,7問だからいいけど,ポーズ以外はコルーチン止めたほうがいいかも.
using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
public class qwach : MonoBehaviour {
public static float Quiztime = 0;//read from global
public GameObject startPanel;
public GameObject startKaitou;
public Text timeTex; //Text用変数
private bool lapTime;
// Use this for initialization
void Start () {
Quiztime = 0f;
startPanel.SetActive (true);
lapTime = false;
timeTex.color = Color.grey;
}
void Awake(){
//StartCoroutine ("colorSwitch");
}
// Update is called once per frame
void Update () {
if (lapTime) {
Quiztime += Time.deltaTime;
timeTex.text = Quiztime.ToString ("f2") + "秒経過";
;
//timeTex.text = timeTex + "秒経過";
//Debug.Log (time.ToString ());
} else {
//pause syori
//StartCoroutine("colorSwitch");
}
}
private IEnumerator colorSwitch(){
while (true) {
timeTex.color = Color.grey;
yield return new WaitForSeconds (0.5f);
timeTex.color = Color.white;
yield return new WaitForSeconds (0.5f);
}
}
public void qwPause(){
StartCoroutine ("colorSwitch");
lapTime = false;
}
public void qwStart(){
StopCoroutine ("colorSwitch");
timeTex.color = Color.white;
lapTime = true;
}
public void qStart(){
lapTime = true;
startPanel.SetActive (false);
timeTex.color = Color.white;
startKaitou.SetActive (true);
}
}