public OilBuilder(CommonAssets commonData) { _firstPool = new GOPool(); _transitPool = new GOPool(); _endPosY = commonData.OilEnd.transform.position.y; _endPool = new GOPool(commonData.OilEnd); }
void Awake() { stonePool = GOPool.Create(25) .Grow(true) .Parent(GO.Create("StonePool")) .Fill(prefabStone.gameObject); splashPool = GOPool.Create(50) .Grow(true) .Parent(GO.Create("SplashPool")) .Fill(prefabSplash.gameObject) .SetOnSpawn(splash => { splash.GetComponent <SkippingSplash>() .onAnimDone.AddListener(OnSplashAnimDone); }); anims = ObjectPool <StoneSkipAnim> .Create(20) .Grow(false) .Fill(i => { return(new StoneSkipAnim { skipCoords = new Vector3[numSkipsPerThrow], splashes = new SkippingSplash[numSkipsPerThrow] }); }) .SetOnDespawn(OnDespawnAnim); playTimes = new float[numSkipsPerThrow]; // Calculate duration time per frame CalcPlayTimes(numSkipsPerThrow, ref playTimes); // get child objects from throwingStones. Pool them and refill // with as many as there are child objects. }
protected override void OnCreatedView() { base.OnCreatedView(); GOPool = new GOPool(Prefab, DataBar); LoggerMgr.Callback_OnAddedLog += OnAddedLog; LoggerMgr.Callback_OnRemoveLog += OnRemoveLog; }
public void Spawn() { GOPool p = GOPool.Create(2).Fill(); Transform t; p.Spawn(out t); Assert.AreEqual(p.numActives, 1); }
public CopterBuilder() { _copterPool = new GOPool(); _missilePool = new GOPool(); _copterQueue = new Queue <GameObject>(); Copter.MissilePool = _missilePool; HomingMissile.SelfPool = _missilePool; }
private GOPool BuildPoolOfSingleType(GameObject type, int size) { GameObject[] singleType = new GameObject[1]; singleType[0] = type; GOPool goPool = BuildPool(singleType, size); return(goPool); }
private GOPool BuildPool(GameObject[] prefabs, int poolsize) { gameObject = Object.Instantiate(new GameObject()); GOPool goPool = gameObject.AddComponent <GOPool>(); goPool.types = prefabs; goPool.poolSize = poolsize; return(goPool); }
public static GOPool Pool(this GO go, int num) { return(GOPool.Create(num) .Fill(i => go.Duplicate().Modify() // set active .SetName(go.GameObject.name + "_" + i) .SetParent(go.Transform.parent) .Transform)); }
public void PoolSize() { Transform parent = new GameObject("Parent").transform; GOPool.Create(5) .Parent(parent) .Fill(); Assert.AreEqual(parent.childCount, 5); }
public void FillResourcesPath() { GOPool p = GOPool.Create(2) .Fill("Cube"); Transform t; p.Spawn(out t); Assert.AreEqual(t.name, "Cube_0"); }
public void LimitGrow() { GOPool <CubeBehaviour> p = GOPool <CubeBehaviour> .Create(1).Fill(); CubeBehaviour cb1; CubeBehaviour cb2; int s = p.Spawn(out cb1) ? 1 : 0; s += p.Spawn(out cb2) ? 1 : 0; Assert.AreEqual(s, 1); }
public void FillResourcesPath() { CubeBehaviour cb; GOPool <CubeBehaviour> .Create(2) .Fill("Cube") .Spawn(out cb); Assert.AreEqual(cb.GetType(), typeof(CubeBehaviour)); }
public IEnumerator SingleTypeMultipleObjects() { GOPool goPool = BuildPoolOfSingleType(new GameObject(), 1); yield return(null); GameObject fromPool = goPool.PopDeactivatedObjectOrReturnNull(); Assert.IsNotNull(fromPool); yield return(null); }
public void DefaultFill() { CubeBehaviour cb; GOPool <CubeBehaviour> .Create(2) .Fill() .Spawn(out cb); Assert.AreEqual(cb.GetType(), typeof(CubeBehaviour)); }
public void Spawn() { GOPool <CubeBehaviour> p = GOPool <CubeBehaviour> .Create(2) .Fill(); CubeBehaviour cb; p.Spawn(out cb); Assert.AreEqual(p.numActives, 1); }
public void LimitGrow() { GOPool p = GOPool.Create(1).Fill(); Transform t1; Transform t2; int s = p.Spawn(out t1) ? 1 : 0; s += p.Spawn(out t2) ? 1 : 0; Assert.AreEqual(s, 1); }
public void Despawn() { CubeBehaviour cb; GOPool <CubeBehaviour> p = GOPool <CubeBehaviour> .Create(2) .Fill(); p.Spawn(out cb); p.Despawn(cb); Assert.AreEqual(p.numActives, 0); }
public void FillResourcesLoad() { GameObject go = Resources.Load <GameObject>("Cube"); GOPool p = GOPool.Create(2) .Fill(go); Transform t; p.Spawn(out t); Assert.AreEqual(go.GetComponent <CubeBehaviour>().GetType(), t.GetComponent <CubeBehaviour>().GetType()); }
public void FillResourcesLoad() { GameObject go = Resources.Load <GameObject>("Cube"); CubeBehaviour cb; GOPool <CubeBehaviour> .Create(2) .Fill(go) .Spawn(out cb); Assert.AreEqual(cb.GetType(), typeof(CubeBehaviour)); }
protected override void OnCreatedView() { base.OnCreatedView(); Title.CancleInit(); DescPool = new GOPool(Desc.gameObject, CanvasGroup.transform); Bg.Init(new BaseImageData { OnClick = OnClickBg }); KeyTip.Init(new BaseTextData { Name = GetKeyTip, IsTrans = false }); Desc.Show(false); }
public void FillReference() { GameObject prefab = Resources.Load <GameObject>("Cube"); GameObject go = GameObject.Instantiate(prefab); CubeBehaviour cb; GOPool <CubeBehaviour> .Create(2) .Fill(go) .Spawn(out cb); Assert.AreEqual(cb.GetType(), typeof(CubeBehaviour)); }
public VehicleBuilder(CommonAssets commonAssets) { _commonAssets = commonAssets; _s1Pool = new GOPool(); _s2Pool = new GOPool(); _s3Pool = new GOPool(); _pPool = new GOPool(); _mPool = new GOPool(); _tPool = new GOPool(); _projectilePool = new GOPool(); ProjectileGun.ProjectilePool = _projectilePool; Projectile.SelfPool = _projectilePool; }
public void FillLambda() { CubeBehaviour cb; GOPool <CubeBehaviour> .Create(2) .Fill(i => { return(new GameObject().AddComponent <CubeBehaviour>()); }) .Spawn(out cb); Assert.AreEqual(cb.GetType(), typeof(CubeBehaviour)); }
public void Initialize(GOPool pool) { Pool = pool; Type = prefab.GetComponent <IBasePoolObject>(); objects = new List <GameObject>(); for (var i = 0; i < cacheSize; i++) { objects.Add(Pool.InstantiateGameObject(prefab, new Vector3(), Quaternion.identity)); objects[i].SetActive(false); objects[i].name = objects[i].name + i; objects[i].transform.parent = Pool.transform; } }
void Start() { GOPool p = GOPool.Create(2) .SetOnSpawn(t => { t.transform.position = Vector3.right; t.gameObject.SetActive(false); }) .Fill("Cube"); Transform i; p.Spawn(out i); }
public void SetParent() { Transform parent = new GameObject("Parent").transform; GOPool p = GOPool.Create(2) .Parent(parent) .Fill(); Transform t; p.Spawn(out t); Assert.AreEqual(t.parent, parent); }
public void SetParent() { Transform parent = new GameObject("Parent").transform; GOPool <CubeBehaviour> p = GOPool <CubeBehaviour> .Create(2) .Parent(parent) .Fill(); CubeBehaviour cb; p.Spawn(out cb); Assert.AreEqual(cb.transform.parent, parent); }
public void FillLambda() { GOPool p = GOPool.Create(2) .Fill(i => { GameObject go = new GameObject("GO"); go.name += "_" + i; return(go.transform); }); Transform t; p.Spawn(out t); Assert.AreEqual(t.name, "GO_0"); }
protected virtual void Awake() { Pool = this; int amount = 0; for (var i = 0; i < caches.Count; i++) { caches[i].Initialize(this); amount += caches[i].cacheSize; } activeCachedObjects = new Hashtable(); // Debug.LogError(gameObject.name); this.Inject(); }
public IEnumerator SingleTypeMultipleSingleObjects() { const int poolSize = 10; GOPool goPool = BuildPoolOfSingleType(new GameObject(), 10); yield return(null); for (int i = 0; i < poolSize; i++) { GameObject fromPool = goPool.PopDeactivatedObjectOrReturnNull(); Assert.IsNotNull(fromPool, "Expected not null @ " + i); fromPool.SetActive(true); } yield return(null); }