「nullに変更」だと、次回のランダム選択候補にnullが出てきて不便そうなので、List方式の方がいいかもしれませんね。
C#
1using UnityEngine;
2using System.Collections.Generic;
3
4public class TrainScript : MonoBehaviour
5{
6 public List<GameObject> Train;
7
8 void Update()
9 {
10 if (Input.GetKeyDown(KeyCode.Space))
11 {
12 if (Train.Count > 0)
13 {
14 var number = Random.Range(0, Train.Count);
15 Instantiate(Train[number], transform.position, transform.rotation);
16 Train.RemoveAt(number);
17 }
18 }
19 }
20}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。