Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.29 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SingletonBehaviour<T> : MonoBehaviour where T : MonoBehaviour
  5. {
  6.     private static T instance;
  7.     public static T Instance
  8.     {
  9.         get
  10.         {
  11.             if (instance == null)
  12.                 instance = FindObjectOfType<T>();
  13.             return instance;
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement