public GameObject SetOwner(IPoolTool value)
        {
            if (owner != null)
            {
                Debug.Log("Owner of a pool should be set only once.");
            }

            owner = value;
            return(gameObject);
        }
Ejemplo n.º 2
0
 protected void Awake()
 {
     pool = GetComponent <IPoolTool>();
 }
Ejemplo n.º 3
0
        public static GameObject WithAutoReturnToPoolAfter(this GameObject gameObject, IPoolTool pool, float time)
        {
            if (gameObject == null)
            {
                return(gameObject);
            }

            var autoReturn = gameObject.GetComponent <PooledObjectAutoReturn>();

            if (autoReturn == null)
            {
                return(gameObject.AddComponent <PooledObjectAutoReturn>().WithLifeTime(time).WithAutoDetachOnReturn(true).SetOwner(pool));
            }
            else
            {
                return(autoReturn.WithTemporaryManualOverride(time).gameObject);
            }
        }