void OnDestroy() { m_referenceCount--; if (m_referenceCount == 0) { m_instance = null; } }
void Start() { GizmoFollow g = (GizmoFollow)FindObjectOfType(typeof(GizmoFollow)); if (g) { gizmo = g.transform; } this.enabled = g; }
void Awake() { m_referenceCount++; if (m_referenceCount > 1) { DestroyImmediate(this.gameObject); return; } m_instance = this; // Use this line if you need the object to persist across scenes //DontDestroyOnLoad(this.gameObject); }