Skip to content

Instantly share code, notes, and snippets.

View gutaussehend-Harshal's full-sized avatar

Harshal Patil gutaussehend-Harshal

View GitHub Profile
@gutaussehend-Harshal
gutaussehend-Harshal / MonoBehaviourSingleton.cs
Created August 3, 2021 04:14 — forked from mstevenson/MonoBehaviourSingleton.cs
Generic Singleton classes for Unity. Use MonoBehaviourSingletonPersistent for any singleton that must survive a level load.
using UnityEngine;
using System.Collections;
public class MonoBehaviourSingleton<T> : MonoBehaviour
where T : Component
{
private static T _instance;
public static T Instance {
get {
if (_instance == null) {