コード例 #1
0
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
コード例 #2
0
 private void Awake()
 {
     if (instance == null)
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     characterBox = gameObject.GetComponent <BoxCollider2D>();
     boundBox     = GameObject.FindGameObjectWithTag("Background").GetComponent <BoxCollider2D>();
 }