LoginSignup
0
0

More than 1 year has passed since last update.

0.5秒後にシーン遷移

Last updated at Posted at 2021-07-14

ボタンを押した時に音がならない問題に遭遇したため、
0.5秒後に遷移する方法を書きました。

   float time; 
   bool flg;

    void Start()
    {
        time = 0;  //初期値を設定
        flg = false;  //初期値はfalse
    }

    public void StartClick()
    {
        flg = true;  //StartClickが押された時にfalseからtrueになる
    }

    void Update()
    {
        if (flg == true)  //flgがtrueになったら実行される
        {
            time = time + Time.deltaTime;  //0にTime.deltaTimeを足す
        }

        if (time >= 0.5f)  //timeが0.5秒経ったらGameMainに遷移される
        {
            SceneManager.LoadScene("GameMain");
        }
    }

これで0.5秒後に遷移されるようになりました!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0