LoginSignup
0
0

More than 3 years have passed since last update.

キー押下でScene再読み込みをする(リロード、リトライ的なもの)

Last updated at Posted at 2020-01-21

実行ボタンのオンオフがめんどくなってきたら、
カメラなどオブジェクトの存在が一定の物に対して、スクリプトをアタッチしておくと楽チン


関連


実質3行の追加で実装完了(中括弧は除く)

必要なのは下記のとおり

Reload.cs

using UnityEngine.SceneManagement; //ここと
using UnityEngine;

public class Reload : MonoBehaviour
{
    void Update()
    {
        //ここから
        if (Input.GetKey(KeyCode.Return))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        //ここまで
    }
}

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