Don't Destroy On Load the Factories

This commit is contained in:
Syntriax 2022-11-21 13:12:44 +03:00
parent e2c1f186af
commit 03499d4692
2 changed files with 10 additions and 0 deletions

View File

@ -22,7 +22,12 @@ namespace Syntriax.Modules.Movement.Config
get get
{ {
if (_instance == null) if (_instance == null)
{
GameObject factoriesGO = GameObject.Find("Factories") ?? new GameObject("Factories");
_instance = new GameObject(Name).AddComponent<MovementDefinitionFactory>(); _instance = new GameObject(Name).AddComponent<MovementDefinitionFactory>();
_instance.transform.SetParent(factoriesGO.transform);
DontDestroyOnLoad(factoriesGO);
}
return _instance; return _instance;
} }

View File

@ -17,7 +17,12 @@ namespace Syntriax.Modules.Movement.Config
get get
{ {
if (_instance == null) if (_instance == null)
{
GameObject factoriesGO = GameObject.Find("Factories") ?? new GameObject("Factories");
_instance = new GameObject(Name).AddComponent<MovementFactory>(); _instance = new GameObject(Name).AddComponent<MovementFactory>();
_instance.transform.SetParent(factoriesGO.transform);
DontDestroyOnLoad(factoriesGO);
}
return _instance; return _instance;
} }