// CSharp单例
public abstract class CSharpSingletion<T> where T : new()
private static T instance;
public static T Instance
{
get
{
if (instance == null)
{
instance = new T();
}
return instance;
}
}
}
// 继承于monobehavior 的单例写法
public class MyGestureListener : MonoBehaviour
{
public static MyGestureListener Instance;
private void Awake()
{
Instance = this;
}
}