优化TSingleton和TEngine使用体验

优化TSingleton和TEngine使用体验
This commit is contained in:
ALEXTANG
2022-06-21 11:39:11 +08:00
parent 887587cbab
commit 231d0c4a69
2 changed files with 11 additions and 2 deletions

View File

@@ -28,7 +28,16 @@ namespace TEngine
{ {
if (_root == null) if (_root == null)
{ {
_root = GameObject.Find("TEngine"); _root = GameObject.Find("TEngineMgr");
if (_root == null)
{
_root = new GameObject("TEngineMgr");
_root.transform.position = Vector3.zero;
}
UnityEngine.Object.DontDestroyOnLoad(_root);
} }
return _root; return _root;

View File

@@ -22,7 +22,7 @@ namespace TEngine
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);