public IEnumerator FindAllRentingPoolObjects() { yield return(SceneManager.LoadSceneAsync("TestScene", LoadSceneMode.Additive)); var testScene = SceneManager.GetSceneByName("TestScene"); SceneManager.SetActiveScene(testScene); var go = new GameObject(); // in TestScene var pool = CreatePool(numberOfInstances: 1); yield return(pool.PreloadAsync().ToYieldInstruction()); yield return(pool.PreactivateAsync().ToYieldInstruction()); var testSceneObj = pool.Rent(); testSceneObj.transform.SetParent(go.transform); var obj = pool.Rent(); var id = obj.GetComponent <PoolObjectController>().Id; var allObjects = ObjectPoolUtils.FindAllRentingPoolObjects(id) .Select(c => c.Behaviour); var enumerator = allObjects.GetEnumerator(); enumerator.MoveNext().IsTrue(); enumerator.Current.Is(testSceneObj); enumerator.MoveNext().IsTrue(); enumerator.Current.Is(obj); foreach (var o in allObjects) { pool.Return(o); } yield return(SceneManager.UnloadSceneAsync(testScene)); }
public IEnumerator AllPoolObjectCanReturnByCallingFindAllRentingPoolObjects() { var numberOfInstances = 3; var pool = CreatePool(numberOfInstances: numberOfInstances); yield return(pool.PreloadAsync().ToYieldInstruction()); yield return(pool.PreactivateAsync().ToYieldInstruction()); pool.Count.Is(numberOfInstances); var obj = pool.Rent(); pool.Count.Is(numberOfInstances - 1); var id = obj.GetComponent <PoolObjectController>().Id; var all = ObjectPoolUtils.FindAllRentingPoolObjects(id); foreach (var o in all) { pool.Return(o.Behaviour); } pool.Count.Is(numberOfInstances); }