// Demonstrates prefab spawning for The Architecture of Play ebook. // Referenced by: docs/ebook/GDnD-Architecture-of-Play.md using UnityEngine; public class PickupSpawner : MonoBehaviour { [SerializeField] private GameObject coinPrefab; [SerializeField] private Transform[] spawnPoints; [SerializeField] private Transform pickupParent; private void Start() { for (int i = 0; i < spawnPoints.Length; i++) { if (spawnPoints[i] == null) { Debug.LogWarning("Spawn point " + i + " is missing."); continue; } GameObject coin = Instantiate( coinPrefab, spawnPoints[i].position, Quaternion.identity ); if (pickupParent != null) { coin.transform.SetParent(pickupParent); } } } }