• This project
    • Loading...
  • Sign in

TelusPlayground / NestApp

Go to a project
Toggle navigation
Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Pipelines
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Network
  • Create a new issue
  • Builds
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • NestApp
  • Assets
  • Packages
  • GlobaTools
  • Utility
  • Singleton.cs
  • Dave Boyle's avatar
    Needs a coat of paint, but it's functionally doing everything it should · 1d630b2a
    1d630b2a Browse Files
    Dave Boyle authored 2016-06-06 13:46:49 -0400
Singleton.cs 320 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
using UnityEngine;

public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
    private static T instance;

    public static T Instance
    {
        get
        {
            if (instance == null)
                instance = (T)FindObjectOfType(typeof(T));

            return instance;
        }
    }
}