骑行页面消息通知
在线用户和影子选手用图片显示,缩放等功能按钮微调
This commit is contained in:
1 parent
2b4b2c4f70
commit
8f0598580d
37 files changed
+5951
-3153
No files matched your search
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoBehaviour
|
||||
{
|
||||
private static T instance = null;
|
||||
|
||||
private static readonly object locker = new object();
|
||||
|
||||
private static bool bAppQuitting;
|
||||
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (bAppQuitting)
|
||||
{
|
||||
instance = null;
|
||||
return instance;
|
||||
}
|
||||
|
||||
lock (locker)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = FindObjectOfType<T>();
|
||||
if (FindObjectsOfType<T>().Length > 1)
|
||||
{
|
||||
Debug.LogError("不应该存在多个单例!");
|
||||
return instance;
|
||||
}
|
||||
|
||||
if (instance == null)
|
||||
{
|
||||
var singleton = new GameObject();
|
||||
instance = singleton.AddComponent<T>();
|
||||
singleton.name = "(singleton)" + typeof(T);
|
||||
singleton.hideFlags = HideFlags.None;
|
||||
DontDestroyOnLoad(singleton);
|
||||
}
|
||||
else
|
||||
DontDestroyOnLoad(instance.gameObject);
|
||||
}
|
||||
instance.hideFlags = HideFlags.None;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
bAppQuitting = false;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
bAppQuitting = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user