witches
This commit is contained in:
parent
ffb1f1caa1
commit
b21d392ff6
80 changed files with 2888 additions and 221 deletions
8
Assets/Scripts/Singletons/Abstract.meta
Normal file
8
Assets/Scripts/Singletons/Abstract.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 378d95684615781798186de36dd1fd98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Scripts/Singletons/Abstract/MonoBehaviourSingleton.cs
Normal file
26
Assets/Scripts/Singletons/Abstract/MonoBehaviourSingleton.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
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) {
|
||||
var objs = FindObjectsByType<T> (FindObjectsSortMode.None) as T[];
|
||||
if (objs.Length > 0)
|
||||
_instance = objs[0];
|
||||
if (objs.Length > 1) {
|
||||
Debug.LogError ("There is more than one " + typeof(T).Name + " in the scene.");
|
||||
}
|
||||
if (_instance == null) {
|
||||
GameObject obj = new GameObject (typeof(T).Name);
|
||||
obj.hideFlags = HideFlags.HideAndDontSave;
|
||||
_instance = obj.AddComponent<T> ();
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1dde3af729030b37d991e70070acee9b
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class MonoBehaviourSingletonPersistent<T> : MonoBehaviour
|
||||
where T : Component
|
||||
{
|
||||
public static T Instance { get; private set; }
|
||||
|
||||
public virtual void Awake ()
|
||||
{
|
||||
if (Instance == null) {
|
||||
Instance = this as T;
|
||||
Instance.name = typeof(T).Name;
|
||||
DontDestroyOnLoad (this);
|
||||
} else {
|
||||
Destroy (gameObject);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a1a48baa3d70ae8fca6a9e23eb62eb1d
|
6
Assets/Scripts/Singletons/CoroutineManager.cs
Normal file
6
Assets/Scripts/Singletons/CoroutineManager.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class CoroutineManager : MonoBehaviourSingleton<CoroutineManager>
|
||||
{
|
||||
}
|
2
Assets/Scripts/Singletons/CoroutineManager.cs.meta
Normal file
2
Assets/Scripts/Singletons/CoroutineManager.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e25f27d44ff1bea9fb02b1e5deeceed8
|
Loading…
Add table
Add a link
Reference in a new issue