SetObjectPosition() public static method

public static SetObjectPosition ( UnityEngine in_gameObjectID, float PosX, float PosY, float PosZ, float FrontX, float FrontY, float FrontZ ) : AKRESULT
in_gameObjectID UnityEngine
PosX float
PosY float
PosZ float
FrontX float
FrontY float
FrontZ float
return AKRESULT
Ejemplo n.º 1
0
    public override void Update()
    {
        Matrix  m       = this.Matrix;
        Vector3 pos     = m.Translation;
        Vector3 forward = m.Forward;

        if (this.pos == pos && this.forward == forward)
        {
            this.hasMoved = false;
            return;
        }

        this.pos      = pos;
        this.forward  = forward;
        this.hasMoved = true;

        // Update position
        AkSoundEngine.SetObjectPosition
        (
            this.Entity,
            pos.X,
            pos.Y,
            pos.Z,
            forward.X,
            forward.Y,
            forward.Z
        );
    }
Ejemplo n.º 2
0
 private void UpdateEditorListenerPosition()
 {
     if (!Application.isPlaying && AkSoundEngine.IsInitialized() && UnityEditor.SceneView.lastActiveSceneView != null && UnityEditor.SceneView.lastActiveSceneView.camera != null)
     {
         AkSoundEngine.SetObjectPosition(gameObject, UnityEditor.SceneView.lastActiveSceneView.camera.transform);
     }
 }
Ejemplo n.º 3
0
    private void Awake()
    {
        if (!this.isStaticObject)
        {
            this.m_posData = new AkGameObjPositionData();
        }
        Collider component = base.GetComponent <Collider>();

        this.coll = component;
        if (component != null)
        {
            this.GameObjColliderBounds = base.GetComponent <Collider>().bounds;
            component.enabled          = false;
        }
        AKRESULT aKRESULT = AkSoundEngine.RegisterGameObj(base.gameObject, base.gameObject.name, (uint)(this.listenerMask & 255));

        if (aKRESULT == AKRESULT.AK_Success)
        {
            Vector3 position = this.GetPosition();
            AkSoundEngine.SetObjectPosition(base.gameObject, position.x, position.y, position.z, base.transform.forward.x, base.transform.forward.y, base.transform.forward.z);
            if (this.isEnvironmentAware)
            {
                this.m_envData = new AkGameObjEnvironmentData();
                this.AddAuxSend(base.gameObject);
            }
        }
    }
        private void AddAkEvent(AkEvent akEvent)
        {
            akEvents.Add(akEvent);

            // In the case where objects are being placed in edit mode and then previewed, their positions won't yet be updated so we ensure they're updated here.
            AkSoundEngine.SetObjectPosition(akEvent.gameObject, akEvent.transform);
        }
Ejemplo n.º 5
0
    void Awake()
    {
#if UNITY_EDITOR
        if (AkUtilities.IsMigrating)
        {
            return;
        }
#endif

        // If the object was marked as static, don't update its position to save cycles.
#if UNITY_EDITOR
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.EditorApplication.update += this.CheckStaticStatus;
            return;
        }
#endif
        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, (uint)(listenerMask & ALL_LISTENER_MASK));
        if (res == AKRESULT.AK_Success)
        {
            // Get position with offset
            Vector3 position = GetPosition();

            //Set the original 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);

            if (isEnvironmentAware)
            {
                m_envData = new AkGameObjEnvironmentData();
                //Check if this object is also an environment.
                AddAuxSend(gameObject);
            }
        }
    }
Ejemplo n.º 6
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);
    }
Ejemplo n.º 7
0
    void Awake()
    {
#if UNITY_EDITOR
        if (AkUtilities.IsMigrating)
        {
            return;
        }

        // If the object was marked as static, don't update its position to save cycles.
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            UnityEditor.EditorApplication.update += this.CheckStaticStatus;
            return;
        }
#endif
        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.
            Vector3 position = GetPosition();
            Vector3 forward  = GetForward();
            Vector3 up       = GetUpward();

            //Set the original position
            AkSoundEngine.SetObjectPosition(
                gameObject,
                position.x, position.y, position.z,
                forward.x, forward.y, forward.z,
                up.x, up.y, up.z);

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

            m_listeners.Initialize();
        }
    }
Ejemplo n.º 8
0
    private void Update()
    {
        Vector3 position = this.GetPosition();

        if ((this.m_posData.position != position) || (this.m_posData.forward != base.transform.forward))
        {
            this.m_posData.position = position;
            this.m_posData.forward  = base.transform.forward;
            AkSoundEngine.SetObjectPosition(base.gameObject, position.x, position.y, position.z, base.transform.forward.x, base.transform.forward.y, base.transform.forward.z);
            if (this.isEnvironmentAware)
            {
                this.UpdateAuxSend();
            }
        }
    }
Ejemplo n.º 9
0
    void Awake()
    {
        //Register a Game Object in the sound engine, with its name.
        AkSoundEngine.RegisterGameObj(gameObject, gameObject.name);

        //Set the original position
        AkSoundEngine.SetObjectPosition(
            gameObject,
            transform.position.x,
            transform.position.y,
            transform.position.z,
            transform.forward.x,
            transform.forward.y,
            transform.forward.z);
    }
Ejemplo n.º 10
0
    private void Awake()
    {
        if (!this.isStaticObject)
        {
            this.m_posData = new AkGameObjPositionData();
        }
        AkSoundEngine.RegisterGameObj(base.gameObject, base.gameObject.name);
        Vector3 position = this.GetPosition();

        AkSoundEngine.SetObjectPosition(base.gameObject, position.x, position.y, position.z, base.transform.forward.x, base.transform.forward.y, base.transform.forward.z);
        if (this.isEnvironmentAware)
        {
            this.m_envData = new AkGameObjEnvironmentData();
            this.AddAuxSend(base.gameObject);
        }
    }
Ejemplo n.º 11
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]);
            }
        }
    }
        public static void PlayEvent(AkEvent akEvent)
        {
            if (akEvents.Contains(akEvent))
            {
                return;
            }

            var playingID = akEvent.data.Post(akEvent.gameObject, (uint)AkCallbackType.AK_EndOfEvent, CallbackHandler, akEvent);

            if (playingID != AkSoundEngine.AK_INVALID_PLAYING_ID)
            {
                akEvents.Add(akEvent);

                // In the case where objects are being placed in edit mode and then previewed, their positions won't yet be updated so we ensure they're updated here.
                AkSoundEngine.SetObjectPosition(akEvent.gameObject, akEvent.transform);
            }
        }
Ejemplo n.º 13
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);
        }
    }
Ejemplo n.º 14
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);
    }
Ejemplo n.º 15
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);
    }
Ejemplo n.º 16
0
    void Awake()
    {
        // If the object was marked as static, don't update its position to save cycles.
#if UNITY_EDITOR
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            //set enabled to true and is static to false to make sure that the update function is called in edit mode
            //the correct value for the isStaticObject variable will be set when update is called
            isStaticObject = false;
            enabled        = true;
            return;
        }
#endif
        if (!isStaticObject)
        {
            m_posData = new AkGameObjPositionData();
        }

        //Register a Game Object in the sound engine, with its name.
        AKRESULT res = AkSoundEngine.RegisterGameObj(gameObject, gameObject.name, (uint)(listenerMask & ALL_LISTENER_MASK));
        if (res == AKRESULT.AK_Success)
        {
            // Get position with offset
            Vector3 position = GetPosition();

            //Set the original position
            AkSoundEngine.SetObjectPosition(
                gameObject,
                position.x,
                position.y,
                position.z,
                transform.forward.x,
                transform.forward.y,
                transform.forward.z);

            if (isEnvironmentAware)
            {
                m_envData = new AkGameObjEnvironmentData();
                //Check if this object is also an environment.
                AddAuxSend(gameObject);
            }
        }
    }
    internal void SetPosition(bool force = false)
    {
        var position = GetPosition();
        var forward  = GetForward();
        var up       = GetUpward();

        if (m_posData != null)
        {
            if (!force && 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;
        }

        AkSoundEngine.SetObjectPosition(gameObject, position, forward, up);
    }
Ejemplo n.º 18
0
    private void Update()
    {
        if (this.isStaticObject)
        {
            return;
        }
        Vector3 position = this.GetPosition();

        if (this.m_posData.position == position && this.m_posData.forward == base.transform.forward)
        {
            return;
        }
        this.m_posData.position = position;
        this.m_posData.forward  = base.transform.forward;
        AkSoundEngine.SetObjectPosition(base.gameObject, position.x, position.y, position.z, base.transform.forward.x, base.transform.forward.y, base.transform.forward.z);
        if (this.isEnvironmentAware)
        {
            this.UpdateAuxSend();
        }
    }
Ejemplo n.º 19
0
    void Update()
    {
#if UNITY_EDITOR
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            return;
        }
#endif
        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)
        {
            return;
        }

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

        //Update position
        AkSoundEngine.SetObjectPosition(
            gameObject,
            position.x,
            position.y,
            position.z,
            transform.forward.x,
            transform.forward.y,
            transform.forward.z);

        if (isEnvironmentAware)
        {
            UpdateAuxSend();
        }
    }
    private void UpdateEditorListenerPosition()
    {
        if (IsPlayingOrIsNotInitialized || editorListenerGameObject == null)
        {
            return;
        }

        if (UnityEditor.SceneView.lastActiveSceneView == null)
        {
            return;
        }

        var sceneViewCamera = UnityEditor.SceneView.lastActiveSceneView.camera;

        if (sceneViewCamera == null)
        {
            return;
        }

        var sceneViewTransform = sceneViewCamera.transform;

        if (sceneViewTransform == null)
        {
            return;
        }

        if (editorListenerPosition == sceneViewTransform.position &&
            editorListenerForward == sceneViewTransform.forward &&
            editorListenerUp == sceneViewTransform.up)
        {
            return;
        }

        AkSoundEngine.SetObjectPosition(editorListenerGameObject, sceneViewTransform);

        editorListenerPosition = sceneViewTransform.position;
        editorListenerForward  = sceneViewTransform.forward;
        editorListenerUp       = sceneViewTransform.up;
    }
Ejemplo n.º 21
0
    public virtual void Update()
    {
        Transform transform = this.Entity.Get <Transform>();

        if (transform != null)
        {
            Vector3 position = transform.Position;
            Vector3 forward  = Vector3.Transform(Vector3.Forward, transform.Quaternion);

            // Set the original position
            AkSoundEngine.SetObjectPosition
            (
                this.Entity,
                position.X,
                position.Y,
                position.Z,
                forward.X,
                forward.Y,
                forward.Z
            );
        }
    }
Ejemplo n.º 22
0
    void Update()
    {
        if (m_Position == transform.position && m_Forward == transform.forward)
        {
            m_bHasMoved = false;
            return;
        }

        m_Position  = transform.position;
        m_Forward   = transform.forward;
        m_bHasMoved = true;

        //Update position
        AkSoundEngine.SetObjectPosition(
            gameObject,
            transform.position.x,
            transform.position.y,
            transform.position.z,
            transform.forward.x,
            transform.forward.y,
            transform.forward.z);

        //Update Object-Listener distance RTPC, if needed. (TODO)
    }
Ejemplo n.º 23
0
 public AKRESULT SetGameObjectPosition(GameObject gameObj, Transform transform)
 {
     return(AkSoundEngine.SetObjectPosition(gameObj, transform));
 }
 public void TransformUpdate(Transform _transform)
 {
     AkSoundEngine.SetObjectPosition(gameObject, _transform);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// 设置Position并且要设置方向
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="position"></param>
 /// <param name="forward"></param>
 /// <param name="up"></param>
 /// <returns></returns>
 public AKRESULT SetGameObjectPosition(GameObject gameObject, Vector3 position, Vector3 forward, Vector3 up)
 {
     return(AkSoundEngine.SetObjectPosition(gameObject, position, forward, up));
 }
Ejemplo n.º 26
0
 public AKRESULT SetGameObjectPosition(GameObject gmaeObject, float posX, float posY, float posZ, float frontX, float frontY, float frontZ, float topX, float topY, float topZ)
 {
     return(AkSoundEngine.SetObjectPosition(gmaeObject, posX, posY, posZ, frontX, frontY, frontZ, topX, topY, topZ));
 }
Ejemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     AkSoundEngine.SetObjectPosition(gameObject, transform.position.x, transform.position.y, transform.position.z, 1f, 0, 0);
 }