Unity5.38を使ってC#で下記のスクリプトを書いたのですが、
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Check : MonoBehaviour
{
public GameObject IP;
public InputManager scripta;
public int A;
public GameObject ST;
public Stage2 scripta1;
public Text scoreText;
public int score = 0;
public int T;
private SoundManager sound;
public float time = 0.0f;
void Start()
{
scoreText.text = " ";
}
// Update is called once per frame void Update() { if (Input.anyKey) { sound = GameObject.Find("SoundManager").GetComponent<SoundManager>(); IP = GameObject.Find("InputManager"); scripta = IP.GetComponent<InputManager>(); A = scripta.Answer; score = A; scoreText.text = " " + score.ToString(); if (time < 5.0f) //時間制限 { time += Time.deltaTime; if (time >= 5.0f) { Debug.Log(A); } } ST = GameObject.Find("Stage"); scripta1 = ST.GetComponent<Stage2>(); T = scripta1.total; if (A == T) { sound.PlayBreak(); Debug.Log("O.K"); } else { sound.PlayMiss(); print("Mistake"); } }
scoreをシーンに表示してからsoundが鳴るように、時間制限を入れたのですが、コンパイルは通ったのですが、表示とsoundが同時で時間制限が働いていないようです。
誰か改善方法を教えてもらえませんか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/04 23:44