Added DOTween;
Added ViewAlignmentDetector; Fixed Object.FindObjectOfType<T>() warning;
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace A2W
|
||||
{
|
||||
@@ -14,29 +14,40 @@ namespace A2W
|
||||
{
|
||||
return null;
|
||||
}
|
||||
lock (_lock)
|
||||
|
||||
if (_instance == null)
|
||||
{
|
||||
if (_instance == null)
|
||||
lock (_lock)
|
||||
{
|
||||
_instance = (T)FindObjectOfType(typeof(T));
|
||||
|
||||
if (FindObjectsOfType(typeof(T)).Length > 1)
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
if (_instance == null)
|
||||
{
|
||||
GameObject singleton = new GameObject();
|
||||
_instance = singleton.AddComponent<T>();
|
||||
singleton.name = "(singleton)" + typeof(T).ToString();
|
||||
var objs = FindObjectsByType<T>(FindObjectsSortMode.None);
|
||||
if (objs.Length > 0)
|
||||
{
|
||||
_instance = objs[0];
|
||||
if (objs.Length > 1)
|
||||
{
|
||||
for (var i = 1; i < objs.Length; i++)
|
||||
{
|
||||
Destroy(objs[i].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(singleton);
|
||||
if (_instance == null)
|
||||
{
|
||||
var singleton = new GameObject();
|
||||
_instance = singleton.AddComponent<T>();
|
||||
singleton.name = "(singleton)" + typeof(T).ToString();
|
||||
|
||||
DontDestroyOnLoad(singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user