using System; using UnityEngine; public class MagicalReference where T : UnityEngine.Object { public T reference { get { if (this._ref == null) { this._ref = UnityEngine.Object.FindObjectOfType(); } return this._ref; } } private T _ref; }