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);
            }
        }
    }
	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);
			}
		}
	}