示例#1
0
    void Update()
    {
#if UNITY_EDITOR
        if (AkUtilities.IsMigrating)
        {
            return;
        }

        if (!UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }
#endif

        if (isEnvironmentAware && m_envData != null)
        {
            m_envData.UpdateAuxSend(gameObject, transform.position);
        }

        if (isStaticObject)
        {
            return;
        }

        // Get position with offset
        Vector3 position = GetPosition();

        //Didn't move.  Do nothing.
        if (m_posData.position == position && m_posData.forward == transform.forward && m_posData.up == transform.up)
        {
            return;
        }

        m_posData.position = position;
        m_posData.forward  = transform.forward;
        m_posData.up       = transform.up;

        //Update position
        AkSoundEngine.SetObjectPosition(
            gameObject,
            position.x,
            position.y,
            position.z,
            transform.forward.x,
            transform.forward.y,
            transform.forward.z,
            transform.up.x,
            transform.up.y,
            transform.up.z);
    }
示例#2
0
    void Awake()
    {
#if UNITY_EDITOR
        if (AkUtilities.IsMigrating)
        {
            return;
        }

        if (!UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.EditorApplication.update += this.CheckStaticStatus;
        }
#endif

        // If the object was marked as static, don't update its position to save cycles.
        if (!isStaticObject)
        {
            m_posData = new AkGameObjPositionData();
        }

        // Cache the bounds to avoid calls to GetComponent()
        m_Collider = GetComponent <Collider>();

        //Register a Game Object in the sound engine, with its name.
        AKRESULT res = AkSoundEngine.RegisterGameObj(gameObject, gameObject.name);
        if (res == AKRESULT.AK_Success)
        {
            // Get position with offset or custom position and orientation.
            //Set the original position
            AkSoundEngine.SetObjectPosition(gameObject, GetPosition(), GetForward(), GetUpward());

            if (isEnvironmentAware && m_Collider)
            {
                m_envData = new AkGameObjEnvironmentData();
                //Check if this object is also an environment.
                m_envData.AddAkEnvironment(m_Collider, m_Collider);

                m_envData.UpdateAuxSend(gameObject, transform.position);
            }

            int Count = m_listeners.initialListenerList.Count;
            for (int ii = 0; ii < Count; ++ii)
            {
                AddListener(m_listeners.initialListenerList[ii]);
            }
        }
    }
示例#3
0
    private void Awake()
    {
#if UNITY_EDITOR
        if (!AkSoundEngineController.Instance.IsSoundEngineLoaded || AkUtilities.IsMigrating)
        {
            return;
        }

        if (!UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.EditorApplication.update += CheckStaticStatus;
        }
#endif

        // If the object was marked as static, don't update its position to save cycles.
        if (!isStaticObject)
        {
            m_posData = new AkGameObjPositionData();
        }

        // Cache the bounds to avoid calls to GetComponent()
        m_Collider = GetComponent <UnityEngine.Collider>();

        //Register a Game Object in the sound engine, with its name.
        if (Register() == AKRESULT.AK_Success)
        {
            // Get position with offset or custom position and orientation.
            //Set the original position
            AkSoundEngine.SetObjectPosition(gameObject, GetPosition(), GetForward(), GetUpward());

            if (isEnvironmentAware)
            {
                m_envData = new AkGameObjEnvironmentData();

                if (m_Collider)
                {
                    m_envData.AddAkEnvironment(m_Collider, m_Collider);
                }

                m_envData.UpdateAuxSend(gameObject, transform.position);
            }

            m_listeners.Init(this);
        }
    }
示例#4
0
    void Update()
    {
#if UNITY_EDITOR
        if (AkUtilities.IsMigrating || !UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }
#endif

        if (isEnvironmentAware && m_envData != null)
        {
            m_envData.UpdateAuxSend(gameObject, transform.position);
        }

        m_listeners.Refresh(gameObject);

        if (isStaticObject)
        {
            return;
        }

        // Get custom position and orientation.
        Vector3 position = GetPosition();
        Vector3 forward  = GetForward();
        Vector3 up       = GetUpward();


        //Didn't move.  Do nothing.
        if (m_posData.position == position && m_posData.forward == forward && m_posData.up == up)
        {
            return;
        }

        m_posData.position = position;
        m_posData.forward  = forward;
        m_posData.up       = up;

        //Update position
        AkSoundEngine.SetObjectPosition(
            gameObject,
            position.x, position.y, position.z,
            forward.x, forward.y, forward.z,
            up.x, up.y, up.z);
    }
示例#5
0
    private void Update()
    {
        if (IsMute)
        {
            return;
        }
#if UNITY_EDITOR
        if (!AkSoundEngineController.Instance.IsSoundEngineLoaded || AkUtilities.IsMigrating ||
            !UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }
#endif


        if (m_envData != null)
        {
            m_envData.UpdateAuxSend(gameObject, transform.position);
        }

        if (isStaticObject)
        {
            return;
        }

        // Get custom position and orientation.
        var position = GetPosition();
        var forward  = GetForward();
        var up       = GetUpward();

        //Didn't move.  Do nothing.
        if (m_posData.position == position && m_posData.forward == forward && m_posData.up == up)
        {
            return;
        }

        m_posData.position = position;
        m_posData.forward  = forward;
        m_posData.up       = up;

        //Update position
        AkSoundEngine.SetObjectPosition(gameObject, position, forward, up);
    }
    private void Update()
    {
#if UNITY_EDITOR
        if (!AkSoundEngineController.Instance.IsSoundEngineLoaded || AkUtilities.IsMigrating ||
            !UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }
#endif

        if (m_envData != null)
        {
            m_envData.UpdateAuxSend(gameObject, transform.position);
        }

        if (!isStaticObject)
        {
            SetPosition();
        }
    }