/// <summary> /// Gets one inactive object from a pool then activates it. If /// the object doesn't exist, a new pool will be created. /// This will call <see cref="IPoolable.OnPoolSpawn"/> /// Additionally it will assign to a category. /// <para></para> /// <b>NOTE</b>: Categories are marked as <see langword="DontDestroyOnLoad"/> /// </summary> /// <param name="prefab">Prefab.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rotation.</param> /// <param name="category">Category.</param> static public GameObject GetFromPool(GameObject prefab, Vector3 pos, Quaternion rot, Category category) { BeginDictionaryOrNewPool(prefab, 1); GameObject obj = pools[prefab].PopFromPool(pos, rot, true).gameObject; obj.transform.SetParent(ScenePools.GetTransform(category)); return(obj); }
/// <summary> /// Gets one inactive object from a pool then activates it. If /// the object doesn't exist, a new pool will be created. /// This will call <see cref="IPoolable.OnPoolSpawn"/> /// Additionally it will assign to a category. /// <para></para> /// <b>NOTE</b>: Categories are marked as <see langword="DontDestroyOnLoad"/> /// </summary> /// <returns>The from pool.</returns> /// <param name="prefab">Prefab.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rotation.</param> /// <param name="category">Category.</param> static public GameObject GetFromPool(GameObject prefab, Vector3 pos, Quaternion rot, Category category) { BeginDictionaryOrNewPool(prefab, 1); GameObject obj = pools[prefab].PopFromPool(pos, rot); obj.transform.SetParent(ScenePools.GetTransform(category)); obj.GetComponent <PoolMember>().OnDeployFromPool(); return(obj); }