public object GetObject(object owner, CryoContainer container, params object[] parameters) { if (IsDestroyed()) { _cached = FindObject(); if (_cached is CryoBehaviour cryoBehaviour) { if (!cryoBehaviour.BuiltUp) { cryoBehaviour.BuildUp(); } } else if (_cached is Component component) { var cryoBuilder = component.GetComponent <CryoBuilder>(); if (cryoBuilder != null && !cryoBuilder.BuiltUp) { cryoBuilder.BuildUp(); } } _lifeTimeManager.Add(this, LifeTime); } return(_cached); }
public InstanceProvider(T instance, ILifeTimeManager lifeTimeManager, LifeTime lifeTime) { _instance = instance; LifeTime = lifeTime; lifeTimeManager.Add(this, LifeTime); }
public object GetObject(object owner, CryoContainer container, params object[] parameters) { var component = FindComponentAt(owner); if (component is CryoBehaviour cryoBehaviour) { if (!cryoBehaviour.BuiltUp) { cryoBehaviour.BuildUp(); } } else { var cryoBuilder = component.GetComponent <CryoBuilder>(); if (cryoBuilder != null && !cryoBuilder.BuiltUp) { cryoBuilder.BuildUp(); } } if (component is IDisposable disposable) { _lifeTimeManager.Add(disposable, LifeTime); } return(component); }
public object GetObject(object owner, CryoContainer container, params object[] parameters) { var obj = _factoryMethod(); container.BuildUp(obj, parameters); if (obj is IDisposable disposable) { _lifeTimeManager.Add(disposable, LifeTime); } return(obj); }
public object GetObject(object owner, CryoContainer container, params object[] parameters) { if (!_exist) { _instance = _factoryMethod(); _exist = true; container.BuildUp(_instance, parameters); _lifeTimeManager.Add(this, LifeTime); } return(_instance); }
public object GetObject(object owner, CryoContainer container, params object[] parameters) { if (!_exist) { UnityEngine.Object prefab = Resources.Load("Singletons/" + typeof(T).Name); var instance = UnityEngine.Object.Instantiate(prefab) as GameObject; instance.name = typeof(T).ToString(); _instance = instance.GetComponent(typeof(T)) as T; _exist = true; container.BuildUp(_instance, parameters); _lifeTimeManager.Add(this, LifeTime); UnityEngine.Object.DontDestroyOnLoad(_instance); } return(_instance); }