Object Pooling
来源:互联网 发布:三维动画制作软件 编辑:程序博客网 时间:2024/06/04 18:43
原文里的static加上就成singleton了感觉意义不大,除非只有子弹用这个pool。
using UnityEngine; using System.Collections; using System.Collections.Generic; public class ObjectPoolScript : MonoBehaviour { public GameObject pooledObject; public int pooledAmount = 20; public bool willGrow = true; public List<GameObject> pooledObjects; void Start () { pooledObjects = new List<GameObject>(); for(int i = 0; i < pooledAmount; i++) { GameObject obj = (GameObject)Instantiate(pooledObject); obj.SetActive(false); pooledObjects.Add(obj); } } public GameObject GetPooledObject() { for(int i = 0; i< pooledObjects.Count; i++) { if(pooledObjects[i] == null) { GameObject obj = (GameObject)Instantiate(pooledObject); obj.SetActive(false); pooledObjects[i] = obj; return pooledObjects[i]; } if(!pooledObjects[i].activeInHierarchy) { return pooledObjects[i]; } } if (willGrow) { GameObject obj = (GameObject)Instantiate(pooledObject); pooledObjects.Add(obj); return obj; } return null; } }
0 0
- Object Pooling
- Using COM+ object pooling with Delphi 6
- Using COM+ object pooling with Delphi 6
- Pooling
- pooling
- Unity 对象池(Object Pooling)理解与简单应用
- Fast and Accurate CNN Object Detector with Scale Dependent Pooling and Cascad Rejection Classifiers
- 【小组会整理】ICLR2016Particular object retrieval with integral max-pooling of CNN activations
- PARTICULAR OBJECT RETRIEVAL WITH INTEGRAL MAX-POOLING OF CNN ACTIVATIONS阅读笔记
- 目标检测“Exploit All the Layers: Fast and Accurate CNN Object Detector with Scale Dependent Pooling and”
- Exploit All the Layers: Fast and Accurate CNN Object Detector with Scale Dependent Pooling 之再阅读
- Connection Pooling
- max pooling
- 池化pooling
- max pooling
- Database Pooling
- RoI Pooling
- max pooling
- 使用 Chef 自动化部署一个 Web 服务器
- 日期组件的实现
- ContentProvider详细介绍(附实例源码)
- leetcode No33. Search in Rotated Sorted Array
- nodejs webSocket 压测工具
- Object Pooling
- 基于keepalived的nginx高可用方案
- leetcode09-Palindrome Number之Java版本
- JsonP跨域请求
- TCP的连接管理
- 资源监控工具Munin
- 通信对象 System.ServiceModel.ServiceHost 无法用于通信,因为其处于“出错”状态。
- 饿了么被罚15万 两家入网餐馆违规却在送外卖
- IE8 下面 background 背景图没显示?都是空格惹的祸