using System; using UnityEngine; public class ThereCanBeOnlyOne : MonoBehaviour { private void Awake() { if (this.Prefab != null) { if (!GameObject.Find(this.Prefab.name)) { GameObject gameObject = UnityEngine.Object.Instantiate(this.Prefab); gameObject.name = this.Prefab.name; } } else { UnityEngine.Debug.LogError("Error prefab not set so There Can't Be Only One", this); } } private void Start() { } public GameObject Prefab; }