public void Reclaim(HeatmapParticle particle) { if (pool == null) { CreatePool(); } pool.Add(particle); particle.Height = 0.01f; particle.gameObject.SetActive(false); }
private void CreatePoolInEditor() { pool = new List <HeatmapParticle>(); if (!Application.isEditor) { poolScene = SceneManager.GetSceneByName(name); if (poolScene.isLoaded) { GameObject[] rootObjects = poolScene.GetRootGameObjects(); for (int i = 0; i < rootObjects.Length; i++) { HeatmapParticle pooledShape = rootObjects[i].GetComponent <HeatmapParticle>(); if (!pooledShape.gameObject.activeSelf) { pool.Add(pooledShape); } } return; } } poolScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive); poolScene.name = name; }
void CreatePool() { pool = new List <HeatmapParticle>(); #if UNITY_EDITOR if (Application.isEditor) { poolScene = SceneManager.GetSceneByName(name); if (poolScene.isLoaded) { GameObject[] rootObjects = poolScene.GetRootGameObjects(); for (int i = 0; i < rootObjects.Length; i++) { HeatmapParticle pooledShape = rootObjects[i].GetComponent <HeatmapParticle>(); if (!pooledShape.gameObject.activeSelf) { pool.Add(pooledShape); } } return; } } #endif poolScene = SceneManager.CreateScene(name); }