Assembly Definition & Improvements
This commit is contained in:
parent
7565da4a9c
commit
49b1bcd578
|
@ -2,7 +2,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Factory
|
namespace Syntriax.Modules.Factory
|
||||||
{
|
{
|
||||||
public abstract class FactorySingleton<T> : MonoBehaviour, IFactory where T : Component, IFactory
|
public abstract class FactorySingleton<T> : MonoBehaviour where T : FactoryBase
|
||||||
{
|
{
|
||||||
public const string ParentName = "Factories";
|
public const string ParentName = "Factories";
|
||||||
private static T _instance = null;
|
private static T _instance = null;
|
||||||
|
@ -13,7 +13,7 @@ namespace Syntriax.Modules.Factory
|
||||||
if (_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
GameObject factoriesGO = GameObject.Find(ParentName) ?? new GameObject(ParentName);
|
GameObject factoriesGO = GameObject.Find(ParentName) ?? new GameObject(ParentName);
|
||||||
_instance = new GameObject(nameof(T)).AddComponent<T>();
|
_instance = new GameObject(typeof(T).Name).AddComponent<T>();
|
||||||
_instance.transform.SetParent(factoriesGO.transform);
|
_instance.transform.SetParent(factoriesGO.transform);
|
||||||
DontDestroyOnLoad(factoriesGO);
|
DontDestroyOnLoad(factoriesGO);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,5 @@ namespace Syntriax.Modules.Factory
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize() => Instance.Initialize();
|
|
||||||
public void Reset() => Instance.Reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,14 @@ namespace Syntriax.Modules.Factory
|
||||||
{
|
{
|
||||||
public interface IFactory
|
public interface IFactory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the <see cref="IFactory"/>
|
||||||
|
/// </summary>
|
||||||
public void Initialize();
|
public void Initialize();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the <see cref="IFactory"/>
|
||||||
|
/// </summary>
|
||||||
public void Reset();
|
public void Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"name": "Syntriax.Modules.Factory"
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d4c952ed5f59c5a449cda1b0080ed841
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue