mirror of
https://github.com/mixandjam/Splatoon-Ink.git
synced 2026-12-05 07:02:17 -06:00
added TNTC paint system shader
This commit is contained in:
52
Assets/Scripts/Utils/Singleton.cs
Normal file
52
Assets/Scripts/Utils/Singleton.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Singleton<T> : MonoBehaviour where T: MonoBehaviour{
|
||||
|
||||
public static bool verbose = false;
|
||||
public static bool keepAlive = true;
|
||||
|
||||
private static T _instance = null;
|
||||
public static T instance {
|
||||
get {
|
||||
if(_instance == null){
|
||||
_instance = GameObject.FindObjectOfType<T>();
|
||||
if(_instance == null){
|
||||
var singletonObj = new GameObject();
|
||||
singletonObj.name = typeof(T).ToString();
|
||||
_instance = singletonObj.AddComponent<T>();
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
static public bool isInstanceAlive{
|
||||
get { return _instance != null; }
|
||||
}
|
||||
|
||||
public virtual void Awake(){
|
||||
if (_instance != null){
|
||||
if(verbose)
|
||||
Debug.Log("SingleAccessPoint, Destroy duplicate instance " + name + " of " + instance.name);
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
_instance = GetComponent<T>();
|
||||
|
||||
if(keepAlive){
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
if (_instance == null){
|
||||
if(verbose)
|
||||
Debug.LogError("SingleAccessPoint<" + typeof(T).Name + "> Instance null in Awake");
|
||||
return;
|
||||
}
|
||||
|
||||
if(verbose)
|
||||
Debug.Log("SingleAccessPoint instance found " + instance.GetType().Name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Utils/Singleton.cs.meta
Normal file
11
Assets/Scripts/Utils/Singleton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a81968a323aba6a44b0bb536a20ba0ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user