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); } } }
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(); } } }
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 OnEnable() { m_envPortal = target as AkEnvironmentPortal; FindOverlappingEnvironments(); for (int i = 0; i < 2; i++) { int index = m_envPortal.envList[i].list.IndexOf(m_envPortal.environments[i]); m_selectedIndex[i] = index == -1 ? 0 : index; } }
void OnEnable() { m_envPortal = target as AkEnvironmentPortal; FindOverlappingEnvironments(); for(int i = 0; i < 2; i++) { int index = m_envPortal.envList[i].list.IndexOf (m_envPortal.environments [i]); m_selectedIndex [i] = index == -1 ? 0 : index; } }
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(); } } }
public void UpdatePortal(AkEnvironmentPortal in_portal) { var envList = new System.Collections.Generic.List <AkEnvironment> [2]; for (var i = 0; i < 2; i++) { if (!IntersectingEnvironments[i].TryGetValue(in_portal.GetInstanceID(), out envList[i])) { envList[i] = new System.Collections.Generic.List <AkEnvironment>(); IntersectingEnvironments[i][in_portal.GetInstanceID()] = envList[i]; } else { envList[i].Clear(); } } //We check if a portal intersects any environment //Iterate in reverse order for safe removal form list while iterating for (var i = EnvironmentList.Count - 1; i >= 0; i--) { if (EnvironmentList[i] != null) { //if there is an intersection if (in_portal.GetComponent <UnityEngine.Collider>().bounds .Intersects(EnvironmentList[i].GetComponent <UnityEngine.Collider>().bounds)) { if (UnityEngine.Vector3.Dot(in_portal.transform.rotation * in_portal.axis, EnvironmentList[i].transform.position - in_portal.transform.position) >= 0) { envList[1].Add(EnvironmentList[i]); } else { envList[0].Add(EnvironmentList[i]); } } } else { EnvironmentList.RemoveAt(i); } } }
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 UpdatePortal(AkEnvironmentPortal in_portal) { List<AkEnvironment>[] envList = new List<AkEnvironment>[2]; for(int i = 0; i < 2; i++) { if(!IntersectingEnvironments[i].TryGetValue(in_portal.GetInstanceID(), out envList[i])) { envList[i] = new List<AkEnvironment>(); IntersectingEnvironments[i][in_portal.GetInstanceID()] = envList[i]; } else { envList[i].Clear(); } } //We check if a portal intersects any environment for(int i = EnvironmentList.Count - 1; i >= 0 ; i--)//Iterate in reverse order for safe removal form list while iterating { if(EnvironmentList[i] != null) { //if there is an intersection if(in_portal.GetComponent<Collider>().bounds.Intersects(EnvironmentList[i].GetComponent<Collider>().bounds)) { //We check if the environment is on the left(negatif side of chosen axis) or right side of the portal if(Vector3.Dot(in_portal.transform.rotation * in_portal.axis, EnvironmentList[i].transform.position - in_portal.transform.position) >= 0) { envList[1].Add(EnvironmentList[i]); } else { envList[0].Add(EnvironmentList[i]); } } } else { EnvironmentList.RemoveAt(i); } } }
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); } }
public void UpdatePortal(AkEnvironmentPortal in_portal) { List <AkEnvironment>[] envList = new List <AkEnvironment> [2]; for (int i = 0; i < 2; i++) { if (!IntersectingEnvironments[i].TryGetValue(in_portal.GetInstanceID(), out envList[i])) { envList[i] = new List <AkEnvironment>(); IntersectingEnvironments[i][in_portal.GetInstanceID()] = envList[i]; } else { envList[i].Clear(); } } //We check if a portal intersects any environment for (int i = EnvironmentList.Count - 1; i >= 0; i--) //Iterate in reverse order for safe removal form list while iterating { if (EnvironmentList[i] != null) { //if there is an intersection if (in_portal.GetComponent <Collider>().bounds.Intersects(EnvironmentList[i].GetComponent <Collider>().bounds)) { //We check if the environment is on the left(negatif side of chosen axis) or right side of the portal if (Vector3.Dot(in_portal.transform.rotation * in_portal.axis, EnvironmentList[i].transform.position - in_portal.transform.position) >= 0) { envList[1].Add(EnvironmentList[i]); } else { envList[0].Add(EnvironmentList[i]); } } } else { EnvironmentList.RemoveAt(i); } } }
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; } } }
private void OnEnable() { m_envPortal = target as AkEnvironmentPortal; m_environments = serializedObject.FindProperty("environments"); m_axis = serializedObject.FindProperty("axis"); m_envList = serializedObject.FindProperty("envList"); FindOverlappingEnvironments(); for (var i = 0; i < AkEnvironmentPortal.MAX_ENVIRONMENTS_PER_PORTAL; i++) { m_selectedIndex[i] = 0; var list = m_envList.GetArrayElementAtIndex(i).FindPropertyRelative("list"); for (var j = 0; j < list.arraySize; ++j) { if (list.GetArrayElementAtIndex(j).objectReferenceValue == m_environments.GetArrayElementAtIndex(i).objectReferenceValue) { m_selectedIndex[i] = j; break; } } } }
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(); } } } }