using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PathologicalGames;//PoolManager
public class Pool_Effect : MonoBehaviour
{
public static Pool_Effect instance;//单例
#region
int coluSize = 1, rowSize = 9999;
SpawnPool spawnPool_effect;
PrefabPool prefabPool_effect;
private string effectPath = "Effects/";
private string[] effectNames = new string[]
{
"Cube",
"Cube1",
"Cube2",
"Cube3",
};//预制体对象名字 数组
#endregion//
private void Awake()
{
instance = this;
createSpawnPool("pool_Effect", "Effect", out spawnPool_effect, false, false, false, false, false, 60f);
}//
// Start is called before the first frame update
void Start()
{
initPool();
}
private void initPool()//初始化对象池
{
foreachInit(effectNames, spawnPool_effect, prefabPool_effect, effectPath, 1);
}//
/// <summary>
/// 创建 生成池
/// </summary>
/// <param name="poolGOName">池子实体 的名称</param>
/// <param name="poolName">池子的名称</param>
/// /// <param name="pool_"></param>
/// <param name="matchPoolLayer">勾选后实例化的游戏对象的Layer将用Prefab默认的。</param>
/// <param name="matchPoolScale">勾选后实例化的游戏对象的缩放比例将全是1,不勾选择用Prefab默认的。</param>
/// <param name="logMessages">是否打印日志信息</param>
/// <param name="dontReparent">勾选后实例化的对象将没有父节点,通通在最上层,建议不要勾选。</param>
/// <param name="dontDestroyOnLoad">如果为true,则将Pool的组GameObject设置为Unity的Object.DontDestroyOnLoad()</param>
/// <param name="maxParticleDespawnTime">停止等待粒子死亡的时间(以秒为单
[Unity][PoolManager]对象池加载多对象
最新推荐文章于 2022-02-07 21:04:04 发布
本文详细介绍了Unity中PoolManager的使用,包括基础应用、处理预制体已存在于spawnPool中的问题、通过名称查找和操作物体、解决物体未消除的状况、如何为Pool中的对象添加脚本并初始化,以及应对对象池过多导致的问题。

最低0.47元/天 解锁文章
829

被折叠的 条评论
为什么被折叠?



