Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
* Credit to:
* http://blog.boredmormongames.com/2014/08/object-pooling.html
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Com.LuisPedroFonseca.ProCamera2D.TopDownShooter
{
public class Pool : MonoBehaviour
{
public GameObject thing;
private List<GameObject> things = new List<GameObject>();
public GameObject nextThing
{
get
{
if (things.Count < 1)
{
GameObject newClone = (GameObject)Instantiate(thing);
newClone.transform.parent = transform;
newClone.SetActive(false);
things.Add(newClone);
PoolMember poolMember = newClone.AddComponent<PoolMember>();
poolMember.pool = this;
}
GameObject clone = things[0];
things.RemoveAt(0);
clone.SetActive(true);
return clone;
}
set
{
value.SetActive(false);
things.Add(value);
}
}
}
}