public void ChangeBus(BusName bus, ref AkEnvironment env) { string busName = System.Enum.GetName(typeof(BusName), bus); int id = (int)AkSoundEngine.GetIDFromString(busName); env.SetAuxBusID(id); }
void CreateAuxBus(Guid componentGuid, int ID) { AkEnvironment[] akEnvironments = gameObject.GetComponents <AkEnvironment>(); bool found = false; for (int i = 0; i < akEnvironments.Length; i++) { if (new Guid(akEnvironments[i].valueGuid) == componentGuid) { found = true; break; } } if (found == false) { AkEnvironment akEnvironment = Undo.AddComponent <AkEnvironment>(gameObject); if (akEnvironment != null) { akEnvironment.valueGuid = componentGuid.ToByteArray(); akEnvironment.SetAuxBusID(ID); } } }
private void AddAuxSend(GameObject in_AuxSendObject) { AkEnvironmentPortal component = in_AuxSendObject.GetComponent <AkEnvironmentPortal>(); if (component != null && this.m_envData != null) { this.m_envData.activePortals.Add(component); for (int i = 0; i < component.environments.Length; i++) { if (component.environments[i] != null) { int num = this.m_envData.activeEnvironments.BinarySearch(component.environments[i], AkEnvironment.s_compareByPriority); if (num < 0) { this.m_envData.activeEnvironments.Insert(~num, component.environments[i]); } } } this.m_envData.auxSendValues = null; this.UpdateAuxSend(); return; } AkEnvironment component2 = in_AuxSendObject.GetComponent <AkEnvironment>(); if (component2 != null && this.m_envData != null) { int num2 = this.m_envData.activeEnvironments.BinarySearch(component2, AkEnvironment.s_compareByPriority); if (num2 < 0) { this.m_envData.activeEnvironments.Insert(~num2, component2); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); } } }
public void RemoveAkEnvironment(Collider environmentCollider, Collider gameObjectCollider) { AkEnvironmentPortal portal = environmentCollider.GetComponent <AkEnvironmentPortal>(); if (portal != null) { for (int i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++) { AkEnvironment env = portal.environments[i]; if (env != null && !gameObjectCollider.bounds.Intersects(env.GetCollider().bounds)) { RemoveEnvironment(env); } } activePortals.Remove(portal); isDirty = true; } else { AkEnvironment env = environmentCollider.GetComponent <AkEnvironment>(); if (env != null && !AkEnvironmentBelongsToActivePortals(env)) { RemoveEnvironment(env); } } }
void OnTriggerExit(Collider other) { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { return; } #endif if (isEnvironmentAware) { AkEnvironmentPortal akPortal = other.gameObject.GetComponent <AkEnvironmentPortal>(); if (akPortal != null) { for (int i = 0; i < 2; i++) { if (akPortal.environments[i] != null) { //We just exited a portal so we remove its environments only if we're not inside of them if (!GetComponent <Collider>().bounds.Intersects(akPortal.environments[i].GetComponent <Collider>().bounds)) { m_envData.activeEnvironments.Remove(akPortal.environments[i]); } } } //remove the portal m_envData.activePortals.Remove(akPortal); //Update and send the auxSendArray m_envData.auxSendValues = null; UpdateAuxSend(); return; } AkEnvironment akEnvironment = other.gameObject.GetComponent <AkEnvironment>(); if (akEnvironment != null) { //we check if the environment belongs to a portal for (int i = 0; i < m_envData.activePortals.Count; i++) { for (int j = 0; j < 2; j++) { if (akEnvironment == m_envData.activePortals[i].environments[j]) { //if it belongs to a portal, then we're inside that portal and we don't remove the environment m_envData.auxSendValues = null; UpdateAuxSend(); return; } } } //if it doesn't belong to a portal, we remove it m_envData.activeEnvironments.Remove(akEnvironment); m_envData.auxSendValues = null; UpdateAuxSend(); return; } } }
void Start() { env = GetComponent <AkEnvironment>(); if (!env) { env = this.gameObject.AddComponent <AkEnvironment>(); GetComponent <Rigidbody>().isKinematic = true; } SetReverb(); }
private void OnEnable() { m_AkEnvironment = target as AkEnvironment; m_priority = serializedObject.FindProperty("priority"); m_isDefault = serializedObject.FindProperty("isDefault"); m_excludeOthers = serializedObject.FindProperty("excludeOthers"); //We move and replace the game object to trigger the OnTriggerStay function ShakeEnvironment(); }
void CreateAuxBus(AkDragDropData DDData) { if (HasSameEnvironment(DDData.guid)) { return; } AkEnvironment akEnvironment = Undo.AddComponent <AkEnvironment>(gameObject); if (akEnvironment != null) { SetTypeValue(ref akEnvironment.valueGuid, ref akEnvironment.m_auxBusID, DDData); } }
void OnTriggerExit(Collider in_other) { if (!UnityEditor.EditorApplication.isPlaying) { AkEnvironment akEnvironment = in_other.GetComponent <AkEnvironment>(); if (akEnvironment != null) { int index = (Vector3.Dot(transform.rotation * axis, akEnvironment.transform.position - transform.position) >= 0) ? 1 : 0; envList[index].list.Remove(akEnvironment); } } }
void AddAuxSend(GameObject in_AuxSendObject) { #if UNITY_EDITOR if (AkUtilities.IsMigrating) { return; } #endif AkEnvironmentPortal akPortal = in_AuxSendObject.GetComponent <AkEnvironmentPortal>(); if (akPortal != null) { m_envData.activePortals.Add(akPortal); for (int i = 0; i < akPortal.environments.Length; i++) { if (akPortal.environments[i] != null) { //Add environment only if its not already there int index = m_envData.activeEnvironments.BinarySearch(akPortal.environments[i], AkEnvironment.s_compareByPriority); if (index < 0) { m_envData.activeEnvironments.Insert(~index, akPortal.environments[i]); //List will still be sorted after insertion } } } //Update and send the auxSendArray m_envData.auxSendValues = null; UpdateAuxSend(); return; } AkEnvironment akEnvironment = in_AuxSendObject.GetComponent <AkEnvironment>(); if (akEnvironment != null) { //Add environment only if its not already there int index = m_envData.activeEnvironments.BinarySearch(akEnvironment, AkEnvironment.s_compareByPriority); if (index < 0) { m_envData.activeEnvironments.Insert(~index, akEnvironment); //List will still be sorted after insertion //Update only if the environment was inserted. //If it wasn't inserted, it means we're inside a portal so we dont update because portals have a highter priority than environments m_envData.auxSendValues = null; UpdateAuxSend(); } } }
private bool AkEnvironmentBelongsToActivePortals(AkEnvironment env) { for (var i = 0; i < activePortals.Count; i++) { for (var j = 0; j < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; j++) { if (env == activePortals[i].environments[j]) { return(true); } } } return(false); }
private string GetEnvironmentName(AkEnvironment in_env) { foreach (var wwu in AkWwiseProjectInfo.GetData().AuxBusWwu) { foreach (var env in wwu.List) { if (in_env.data.Id == env.Id) { return(env.Name); } } } return(string.Empty); }
string GetEnvironmentName(AkEnvironment in_env) { for (int i = 0; i < AkWwiseProjectInfo.GetData().AuxBusWwu.Count; i++) { for (int j = 0; j < AkWwiseProjectInfo.GetData().AuxBusWwu[i].List.Count; j++) { if (in_env.GetAuxBusID() == (uint)AkWwiseProjectInfo.GetData().AuxBusWwu[i].List[j].ID) { return(AkWwiseProjectInfo.GetData().AuxBusWwu[i].List[j].Name); } } } return(String.Empty); }
private void UpdateAuxSend() { if (this.m_envData == null) { return; } if (this.m_envData.auxSendValues == null) { this.m_envData.auxSendValues = new AkAuxSendArray((uint)((this.m_envData.activeEnvironments.Count >= AkEnvironment.MAX_NB_ENVIRONMENTS) ? AkEnvironment.MAX_NB_ENVIRONMENTS : this.m_envData.activeEnvironments.Count)); } else { this.m_envData.auxSendValues.Reset(); } for (int i = 0; i < this.m_envData.activePortals.Count; i++) { for (int j = 0; j < this.m_envData.activePortals[i].environments.Length; j++) { AkEnvironment akEnvironment = this.m_envData.activePortals[i].environments[j]; if (akEnvironment != null && this.m_envData.activeEnvironments.BinarySearch(akEnvironment, AkEnvironment.s_compareByPriority) < AkEnvironment.MAX_NB_ENVIRONMENTS) { this.m_envData.auxSendValues.Add(akEnvironment.GetAuxBusID(), this.m_envData.activePortals[i].GetAuxSendValueForPosition(base.transform.position, j)); } } } if ((ulong)this.m_envData.auxSendValues.m_Count < (ulong)((long)AkEnvironment.MAX_NB_ENVIRONMENTS) && (ulong)this.m_envData.auxSendValues.m_Count < (ulong)((long)this.m_envData.activeEnvironments.Count)) { List <AkEnvironment> list = new List <AkEnvironment>(this.m_envData.activeEnvironments); list.Sort(AkEnvironment.s_compareBySelectionAlgorithm); int num = Math.Min(AkEnvironment.MAX_NB_ENVIRONMENTS - (int)this.m_envData.auxSendValues.m_Count, this.m_envData.activeEnvironments.Count - (int)this.m_envData.auxSendValues.m_Count); for (int k = 0; k < num; k++) { if (!this.m_envData.auxSendValues.Contains(list[k].GetAuxBusID())) { if (!list[k].isDefault || k == 0) { this.m_envData.auxSendValues.Add(list[k].GetAuxBusID(), list[k].GetAuxSendValueForPosition(base.transform.position)); if (list[k].excludeOthers) { break; } } } } } AkSoundEngine.SetGameObjectAuxSendValues(base.gameObject, this.m_envData.auxSendValues, this.m_envData.auxSendValues.m_Count); }
private void OnEnable() { m_AkEnvironment = target as AkEnvironment; m_auxBusId = serializedObject.FindProperty("m_auxBusID"); m_priority = serializedObject.FindProperty("priority"); m_isDefault = serializedObject.FindProperty("isDefault"); m_excludeOthers = serializedObject.FindProperty("excludeOthers"); m_guidProperty = new[] { serializedObject.FindProperty("valueGuid.Array") }; //Needed by the base class to know which type of component its working with m_typeName = "AuxBus"; m_objectType = AkWwiseProjectData.WwiseObjectType.AUXBUS; //We move and replace the game object to trigger the OnTriggerStay function ShakeEnvironment(); }
public void AddAkEnvironment(Collider environmentCollider, Collider gameObjectCollider) { AkEnvironmentPortal portal = environmentCollider.GetComponent <AkEnvironmentPortal>(); if (portal != null) { activePortals.Add(portal); for (int i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++) { TryAddEnvironment(portal.environments[i]); } } else { AkEnvironment env = environmentCollider.GetComponent <AkEnvironment>(); TryAddEnvironment(env); } }
public void AddAkEnvironment(GameObject in_AuxSendObject, GameObject gameObject) { AkEnvironmentPortal portal = in_AuxSendObject.GetComponent <AkEnvironmentPortal>(); if (portal != null) { activePortals.Add(portal); for (int i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++) { TryAddEnvironment(portal.environments[i]); } } else { AkEnvironment env = in_AuxSendObject.GetComponent <AkEnvironment>(); TryAddEnvironment(env); } }
private void TryAddEnvironment(AkEnvironment env) { if (env != null) { var index = activeEnvironmentsFromPortals.BinarySearch(env, AkEnvironment.s_compareByPriority); if (index < 0) { activeEnvironmentsFromPortals.Insert(~index, env); index = activeEnvironments.BinarySearch(env, AkEnvironment.s_compareBySelectionAlgorithm); if (index < 0) { activeEnvironments.Insert(~index, env); } isDirty = true; } } }
public override int Compare(AkEnvironment a, AkEnvironment b) { if (a.isDefault) { return((b.isDefault) ? base.Compare(a, b) : 1); } else if (b.isDefault) { return(-1); } else if (a.excludeOthers) { return((b.excludeOthers) ? base.Compare(a, b) : -1); } else { return((b.excludeOthers) ? 1 : base.Compare(a, b)); } }
private void OnTriggerExit(Collider other) { if (this.isEnvironmentAware) { AkEnvironmentPortal component = other.gameObject.GetComponent <AkEnvironmentPortal>(); if (component != null) { for (int i = 0; i < 2; i++) { if ((component.environments[i] != null) && !base.GetComponent <Collider>().bounds.Intersects(component.environments[i].GetComponent <Collider>().bounds)) { this.m_envData.activeEnvironments.Remove(component.environments[i]); } } this.m_envData.activePortals.Remove(component); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); } else { AkEnvironment item = other.gameObject.GetComponent <AkEnvironment>(); if (item != null) { for (int j = 0; j < this.m_envData.activePortals.Count; j++) { for (int k = 0; k < 2; k++) { if (item == this.m_envData.activePortals[j].environments[k]) { this.m_envData.auxSendValues = null; this.UpdateAuxSend(); return; } } } this.m_envData.activeEnvironments.Remove(item); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); } } } }
private void OnTriggerExit(Collider other) { if (this.isEnvironmentAware && this.coll != null && this.m_envData != null) { AkEnvironmentPortal component = other.gameObject.GetComponent <AkEnvironmentPortal>(); if (component != null) { for (int i = 0; i < component.environments.Length; i++) { if (component.environments[i] != null && !this.GameObjColliderBounds.Intersects(component.environments[i].GetComponent <Collider>().bounds)) { this.m_envData.activeEnvironments.Remove(component.environments[i]); } } this.m_envData.activePortals.Remove(component); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); return; } AkEnvironment component2 = other.gameObject.GetComponent <AkEnvironment>(); if (component2 != null && this.m_envData != null) { for (int j = 0; j < this.m_envData.activePortals.Count; j++) { for (int k = 0; k < this.m_envData.activePortals[j].environments.Length; k++) { if (component2 == this.m_envData.activePortals[j].environments[k]) { this.m_envData.auxSendValues = null; this.UpdateAuxSend(); return; } } } this.m_envData.activeEnvironments.Remove(component2); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); return; } } }
// <summary> // Make sure that the intersecting environment is still in the right list (envList[0](negative side) or envList[1](positive side)) // </summary> // <param name="in_other">In_other.</param> void OnTriggerStay(Collider in_other) { if (!UnityEditor.EditorApplication.isPlaying) { AkEnvironment akEnvironment = in_other.GetComponent <AkEnvironment>(); if (akEnvironment != null) { //if index == 0 => the environment is on the negative side of the portal(opposite to the direction of the chosen axis) //if index == 1 => the environment is on the positive side of the portal(same direction as the chosen axis) int index = (Vector3.Dot(transform.rotation * axis, akEnvironment.transform.position - transform.position) >= 0) ? 1 : 0; if (!envList[index].list.Contains(akEnvironment)) { envList[index].list.Add(akEnvironment); envList[++index % 2].list.Remove(akEnvironment); } } } }
private void UpdateAuxSend() { if (this.m_envData.auxSendValues == null) { this.m_envData.auxSendValues = new AkAuxSendArray((this.m_envData.activeEnvironments.Count >= AkEnvironment.MAX_NB_ENVIRONMENTS) ? ((uint)AkEnvironment.MAX_NB_ENVIRONMENTS) : ((uint)this.m_envData.activeEnvironments.Count)); } else { this.m_envData.auxSendValues.Reset(); } for (int i = 0; i < this.m_envData.activePortals.Count; i++) { for (int j = 0; j < 2; j++) { AkEnvironment item = this.m_envData.activePortals[i].environments[j]; if ((item != null) && (this.m_envData.activeEnvironments.BinarySearch(item, AkEnvironment.s_compareByPriority) < AkEnvironment.MAX_NB_ENVIRONMENTS)) { this.m_envData.auxSendValues.Add(item.GetAuxBusID(), this.m_envData.activePortals[i].GetAuxSendValueForPosition(base.transform.position, j)); } } } if ((this.m_envData.auxSendValues.m_Count < AkEnvironment.MAX_NB_ENVIRONMENTS) && (this.m_envData.auxSendValues.m_Count < this.m_envData.activeEnvironments.Count)) { ListView <AkEnvironment> view = new ListView <AkEnvironment>(this.m_envData.activeEnvironments); view.Sort(AkEnvironment.s_compareBySelectionAlgorithm); int num3 = Math.Min((int)(AkEnvironment.MAX_NB_ENVIRONMENTS - ((int)this.m_envData.auxSendValues.m_Count)), (int)(this.m_envData.activeEnvironments.Count - ((int)this.m_envData.auxSendValues.m_Count))); for (int k = 0; k < num3; k++) { if (!this.m_envData.auxSendValues.Contains(view[k].GetAuxBusID()) && (!view[k].isDefault || (k == 0))) { this.m_envData.auxSendValues.Add(view[k].GetAuxBusID(), view[k].GetAuxSendValueForPosition(base.transform.position)); if (view[k].excludeOthers) { break; } } } } AkSoundEngine.SetGameObjectAuxSendValues(base.gameObject, this.m_envData.auxSendValues, this.m_envData.auxSendValues.m_Count); }
private void AddHighestPriorityEnvironments(Vector3 position) { if (!auxSendValues.isFull && auxSendValues.Count() < activeEnvironments.Count) { for (int i = 0; i < activeEnvironments.Count; i++) { AkEnvironment env = activeEnvironments[i]; uint auxBusID = env.GetAuxBusID(); if ((!env.isDefault || i == 0) && !auxSendValues.Contains(auxBusID)) { auxSendValues.Add(auxBusID, env.GetAuxSendValueForPosition(position)); //No other environment can be added after an environment with the excludeOthers flag set to true if (env.excludeOthers || auxSendValues.isFull) { break; } } } } }
private void AddHighestPriorityEnvironmentsFromPortals(Vector3 position) { for (int i = 0; i < activePortals.Count; i++) { for (int j = 0; j < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; j++) { AkEnvironment env = activePortals[i].environments[j]; if (env != null) { int index = activeEnvironmentsFromPortals.BinarySearch(env, AkEnvironment.s_compareByPriority); if (index >= 0 && index < AkEnvironment.MAX_NB_ENVIRONMENTS) { auxSendValues.Add(env.GetAuxBusID(), activePortals[i].GetAuxSendValueForPosition(position, j)); if (auxSendValues.isFull) { return; } } } } } }
void OnEnable() { m_AkEnvironment = target as AkEnvironment; m_AkEnvironment.GetComponent <Rigidbody>().useGravity = false; m_AkEnvironment.GetComponent <Rigidbody>().isKinematic = true; m_AkEnvironment.GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous; m_auxBusId = serializedObject.FindProperty("m_auxBusID"); m_priority = serializedObject.FindProperty("priority"); m_isDefault = serializedObject.FindProperty("isDefault"); m_excludeOthers = serializedObject.FindProperty("excludeOthers"); m_guidProperty = new SerializedProperty[1]; m_guidProperty[0] = serializedObject.FindProperty("valueGuid.Array"); //Needed by the base class to know which type of component its working with m_typeName = "AuxBus"; m_objectType = AkWwiseProjectData.WwiseObjectType.AUXBUS; //We move and replace the game object to trigger the OnTriggerStay function ShakeEnvironment(); }
void OnEnable() { m_AkEnvironment = target as AkEnvironment; m_AkEnvironment.GetComponent<Rigidbody>().useGravity = false; m_AkEnvironment.GetComponent<Rigidbody>().isKinematic = true; m_AkEnvironment.GetComponent<Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous; m_auxBusId = serializedObject.FindProperty ("m_auxBusID"); m_priority = serializedObject.FindProperty ("priority"); m_isDefault = serializedObject.FindProperty ("isDefault"); m_excludeOthers = serializedObject.FindProperty ("excludeOthers"); m_guidProperty = new SerializedProperty[1]; m_guidProperty[0] = serializedObject.FindProperty("valueGuid.Array"); //Needed by the base class to know which type of component its working with m_typeName = "AuxBus"; m_objectType = AkWwiseProjectData.WwiseObjectType.AUXBUS; //We move and replace the game object to trigger the OnTriggerStay function ShakeEnvironment (); }
private void UpdateEnvironment(AkEnvironment in_env) { for (var i = PortalList.Count - 1; i >= 0; i--) //Iterate in reverse order for safe removal form list while iterating { if (PortalList[i] != null) { if (in_env.GetComponent <UnityEngine.Collider>().bounds .Intersects(PortalList[i].GetComponent <UnityEngine.Collider>().bounds)) { System.Collections.Generic.List <AkEnvironment> envList = null; //Get index of the list that should contain this environment //Index = 0 means that the enviroment is on the negative side of the portal (opposite to the direction of the chosen axis) //Index = 1 means that the enviroment is on the positive side of the portal (same direction as the chosen axis) var index = UnityEngine.Vector3.Dot(PortalList[i].transform.rotation * PortalList[i].axis, in_env.transform.position - PortalList[i].transform.position) >= 0 ? 1 : 0; if (!IntersectingEnvironments[index].TryGetValue(PortalList[i].GetInstanceID(), out envList)) { envList = new System.Collections.Generic.List <AkEnvironment>(); envList.Add(in_env); IntersectingEnvironments[index][PortalList[i].GetInstanceID()] = envList; } else if (!envList.Contains(in_env)) { envList.Add(in_env); } } } else { PortalList.RemoveAt(i); } } }
private void AddAuxSend(GameObject in_AuxSendObject) { AkEnvironmentPortal component = in_AuxSendObject.GetComponent <AkEnvironmentPortal>(); if (component != null) { this.m_envData.activePortals.Add(component); for (int i = 0; i < 2; i++) { if (component.environments[i] != null) { int num2 = this.m_envData.activeEnvironments.BinarySearch(component.environments[i], AkEnvironment.s_compareByPriority); if (num2 < 0) { this.m_envData.activeEnvironments.Insert(~num2, component.environments[i]); } } } this.m_envData.auxSendValues = null; this.UpdateAuxSend(); } else { AkEnvironment item = in_AuxSendObject.GetComponent <AkEnvironment>(); if (item != null) { int num3 = this.m_envData.activeEnvironments.BinarySearch(item, AkEnvironment.s_compareByPriority); if (num3 < 0) { this.m_envData.activeEnvironments.Insert(~num3, item); this.m_envData.auxSendValues = null; this.UpdateAuxSend(); } } } }
private void TryAddEnvironment(AkEnvironment env) { if (env == null) { return; } var index = activeEnvironmentsFromPortals.BinarySearch(env, AkEnvironment.s_compareByPriority); if (index >= 0) { return; } activeEnvironmentsFromPortals.Insert(~index, env); index = activeEnvironments.BinarySearch(env, AkEnvironment.s_compareBySelectionAlgorithm); if (index < 0) { activeEnvironments.Insert(~index, env); } hasEnvironmentListChanged = true; }
void UpdateAuxSend() { #if UNITY_EDITOR if (AkUtilities.IsMigrating) { return; } #endif if (m_envData.auxSendValues == null) { #if UNITY_PS4 // Workaround for PS4. Marshall.FreeHGlobal crashes the game, so we need to avoid resizing the array. // Allocate 4 entries right away to avoid the resize. m_envData.auxSendValues = new AkAuxSendArray((uint)AkEnvironment.MAX_NB_ENVIRONMENTS); #else m_envData.auxSendValues = new AkAuxSendArray(m_envData.activeEnvironments.Count < AkEnvironment.MAX_NB_ENVIRONMENTS ? (uint)m_envData.activeEnvironments.Count : (uint)AkEnvironment.MAX_NB_ENVIRONMENTS ); #endif } else { m_envData.auxSendValues.Reset(); } //we search for MAX_NB_ENVIRONMENTS(4 at this time) environments with the hightest priority that belong to a portal and add them to the auxSendArray for (int i = 0; i < m_envData.activePortals.Count; i++) { for (int j = 0; j < m_envData.activePortals[i].environments.Length; j++) { AkEnvironment env = m_envData.activePortals[i].environments[j]; if (env != null) { if (m_envData.activeEnvironments.BinarySearch(env, AkEnvironment.s_compareByPriority) < AkEnvironment.MAX_NB_ENVIRONMENTS) { m_envData.auxSendValues.Add(env.GetAuxBusID(), m_envData.activePortals[i].GetAuxSendValueForPosition(transform.position, j)); } } } } //if we still dont have MAX_NB_ENVIRONMENTS in the auxSendArray, we add the next environments with the hightest priority until we reach MAX_NB_ENVIRONMENTS //or run out of environments if (m_envData.auxSendValues.m_Count < AkEnvironment.MAX_NB_ENVIRONMENTS && m_envData.auxSendValues.m_Count < m_envData.activeEnvironments.Count) { //Make a copy of all environments List <AkEnvironment> sortedEnvList = new List <AkEnvironment>(m_envData.activeEnvironments); //sort the list with the selection algorithm sortedEnvList.Sort(AkEnvironment.s_compareBySelectionAlgorithm); int environmentsLeft = Math.Min(AkEnvironment.MAX_NB_ENVIRONMENTS - (int)m_envData.auxSendValues.m_Count, m_envData.activeEnvironments.Count - (int)m_envData.auxSendValues.m_Count); for (int i = 0; i < environmentsLeft; i++) { if (!m_envData.auxSendValues.Contains(sortedEnvList[i].GetAuxBusID())) { //An environment with the isDefault flag set to true is added only if its the only environment. //Since an environment with the isDefault flag has the lowest priority, it will be at index zero only if there is no other environment if (sortedEnvList[i].isDefault && i != 0) { continue; } m_envData.auxSendValues.Add(sortedEnvList[i].GetAuxBusID(), sortedEnvList[i].GetAuxSendValueForPosition(transform.position)); //No other environment can be added after an environment with the excludeOthers flag set to true if (sortedEnvList[i].excludeOthers) { break; } } } } AkSoundEngine.SetGameObjectAuxSendValues(gameObject, m_envData.auxSendValues, m_envData.auxSendValues.m_Count); }
string GetEnvironmentName(AkEnvironment in_env) { for(int i = 0; i < AkWwiseProjectInfo.GetData().AuxBusWwu.Count; i++) { for(int j = 0; j < AkWwiseProjectInfo.GetData().AuxBusWwu[i].List.Count; j++) { if(in_env.GetAuxBusID() == (uint)AkWwiseProjectInfo.GetData().AuxBusWwu[i].List[j].ID) { return AkWwiseProjectInfo.GetData().AuxBusWwu[i].List[j].Name; } } } return String.Empty; }
void UpdateEnvironment(AkEnvironment in_env) { for(int i = PortalList.Count -1; i >= 0 ; i--)//Iterate in reverse order for safe removal form list while iterating { if(PortalList[i] != null) { if(in_env.GetComponent<Collider>().bounds.Intersects(PortalList[i].GetComponent<Collider>().bounds)) { List<AkEnvironment> envList = null; //Get index of the list that should contain this environment //Index = 0 means that the enviroment is on the negative side of the portal (opposite to the direction of the chosen axis) //Index = 1 means that the enviroment is on the positive side of the portal (same direction as the chosen axis) int index = (Vector3.Dot(PortalList[i].transform.rotation * PortalList[i].axis, in_env.transform.position - PortalList[i].transform.position) >= 0) ? 1 : 0; if(!IntersectingEnvironments[index].TryGetValue(PortalList[i].GetInstanceID(), out envList)) { envList = new List<AkEnvironment>(); envList.Add(in_env); IntersectingEnvironments[index][PortalList[i].GetInstanceID()] = envList; } else { if(!envList.Contains(in_env)) { envList.Add(in_env); } } } } else { PortalList.RemoveAt(i); } } }