Esempio n. 1
0
        /// Restores the pose recieved callbacks that were saved off with DisablePoseTracking. Will merge
        /// any callbacks currently on OnControllerNewPoses.
        public void RestorePoseTracking()
        {
            if (m_OldOnPoseApplied != null)
            {
                if (NewControllerPosesApplied != null)
                {
                    var list = m_OldOnPoseApplied.Concat(NewControllerPosesApplied.GetInvocationList())
                               .Distinct().Cast <Action>();
                    NewControllerPosesApplied = null;
                    foreach (var handler in list)
                    {
                        NewControllerPosesApplied += handler;
                    }
                }
            }

            // Restore camera xf.
            if (m_TrackingBackupXf != null)
            {
                Transform camXf = GetVrCamera().transform;
                camXf.position     = m_TrackingBackupXf.Value.translation;
                camXf.rotation     = m_TrackingBackupXf.Value.rotation;
                camXf.localScale   = Vector3.one;
                m_TrackingBackupXf = null;
            }
        }
Esempio n. 2
0
        // -------------------------------------------------------------------------------------------- //
        // Tracking Methods
        // -------------------------------------------------------------------------------------------- //

        /// Clears the callbacks that get called when a new pose is received. The callbacks are saved
        /// So that they can be restored later with RestorePoseTracking.
        public void DisablePoseTracking()
        {
            m_TrackingBackupXf = TrTransform.FromTransform(GetVrCamera().transform);
            if (NewControllerPosesApplied == null)
            {
                m_OldOnPoseApplied = Array.Empty <Action>();
            }
            else
            {
                m_OldOnPoseApplied = NewControllerPosesApplied.GetInvocationList().Cast <Action>().ToArray();
            }
            NewControllerPosesApplied = null;
        }