// move this 3 lines to top of your class
using System.Collections.Generic;
using Random = UnityEngine.Random;
using Unity.Mathematics;
// put this inside your class
public List<GameObject> prefabsList = new List<GameObject>();
public List<Transform> redSquaresList = new List<Transform>();
private void Start()
{
var randomPrefab = Random.Range(0, prefabsList.Count);
var randomSquare = Random.Range(0, redSquaresList.Count);
Instantiate(prefabsList[randomPrefab], redSquaresList[randomSquare].position, quaternion.identity);
}
1条答案
按热度按时间fjnneemd1#
抄这个:
然后根据需要在编辑器中填充这些列表