SoundOrigin NewSound() { SoundOrigin sound = Instantiate(soundOriginPrefab); SceneManager.MoveGameObjectToScene(sound.gameObject, poolScene); sound.particleSoundFactory = this; sound.entity = entityManager.CreateEntity(soundOriginEntityArchetype); return(sound); }
public void Start() { entityManager = World.Active.EntityManager; soundOriginEntityArchetype = entityManager.CreateArchetype( typeof(Timer), typeof(Translation), typeof(SoundProperties)); timerReset = new Timer { isOn = true, maxT = 0, T = 0 }; soundPropertiesReset = new SoundProperties { syncMap = false, branchCount = 0, baseColor = Color.white, actualColor = Color.white }; rigidBodyComponentsReset = new RigidBodyComponents { position = Vector3.zero, rotation = Quaternion.identity }; soundPool = new List <SoundOrigin>(); if (Application.isEditor) { poolScene = SceneManager.GetSceneByName(name); if (poolScene.isLoaded) { GameObject[] rootObjects = poolScene.GetRootGameObjects(); for (int i = 0; i < rootObjects.Length; i++) { SoundOrigin pooledSound = rootObjects[i].GetComponent <SoundOrigin>(); if (pooledSound != null && !pooledSound.gameObject.activeSelf) { soundPool.Add(pooledSound); } } return; } } poolScene = SceneManager.CreateScene(name); }
void ResetSound(bool syncMap, SoundOrigin instance, int loudNess, Vector2 originPosition, int radius, int colorIndex, float lifeTime, int width, bool bounce) { timerReset.maxT = lifeTime; timerReset.T = 0; timerReset.isOn = true; soundPropertiesReset.colorIndex = colorIndex; soundPropertiesReset.branchCount = loudNess; soundPropertiesReset.radius = radius; soundPropertiesReset.width = width; soundPropertiesReset.bounce = bounce; soundPropertiesReset.syncMap = syncMap; if (colorIndex >= 0 && colorIndex < colors.Length) { soundPropertiesReset.baseColor = colors[colorIndex]; } else { soundPropertiesReset.baseColor = Color.white; } rigidBodyComponentsReset.position = originPosition; instance.SoundOriginStart(ref rigidBodyComponentsReset, ref soundPropertiesReset, ref timerReset); }
public void ReclaimSound(SoundOrigin soundToRecycle) { soundPool.Add(soundToRecycle); }