mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update UnitySingleton.cs
This commit is contained in:
@@ -17,7 +17,7 @@ namespace GameBase
|
|||||||
{
|
{
|
||||||
if (_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
var ins = UnityEngine.Object.FindObjectOfType<T>();
|
var ins = FindObjectOfType<T>();
|
||||||
if (ins != null)
|
if (ins != null)
|
||||||
{
|
{
|
||||||
var obj = ins.gameObject;
|
var obj = ins.gameObject;
|
||||||
@@ -32,11 +32,16 @@ namespace GameBase
|
|||||||
GameObject go = SingletonMgr.GetGameObject(instName);
|
GameObject go = SingletonMgr.GetGameObject(instName);
|
||||||
if (go == null)
|
if (go == null)
|
||||||
{
|
{
|
||||||
go = GameObject.Find($"{instName}");
|
go = GameObject.Find($"[{instName}]");
|
||||||
if (go == null)
|
if (go == null)
|
||||||
{
|
{
|
||||||
go = new GameObject(instName);
|
go = new GameObject($"[{instName}]")
|
||||||
go.transform.position = Vector3.zero;
|
{
|
||||||
|
transform =
|
||||||
|
{
|
||||||
|
position = Vector3.zero
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +106,9 @@ namespace GameBase
|
|||||||
|
|
||||||
public static void Release()
|
public static void Release()
|
||||||
{
|
{
|
||||||
if (_instance != null)
|
if (_instance == null) return;
|
||||||
{
|
SingletonMgr.Release(_instance.gameObject);
|
||||||
SingletonMgr.Release(_instance.gameObject);
|
_instance = null;
|
||||||
_instance = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user