Пример #1
0
 private void SendMessagesBtn_Click(object sender, RoutedEventArgs e)
 {
     RunOnUiThread(() =>
     {
         //_webRtcControl.SendPeerMessageData(MessageInputText.Text);
         _webRtcControl.SendPeerDataChannelMessage(MessageInputText.Text);
     });
 }
    void Update()
    {
        #region Virtual Camera Control

        if (Vector3.Distance(prevPos, VirtualCamera.position) > 0.05f ||
            Quaternion.Angle(prevRot, VirtualCamera.rotation) > 2f)
        {
            prevPos = VirtualCamera.position;
            prevRot = VirtualCamera.rotation;
            var eulerRot = prevRot.eulerAngles;
            var lookAt   = VirtualCamera.forward;
            var upVector = -VirtualCamera.up;
            var format   = @"{{""type"":""camera-transform-lookat"",""body"":""{0},{1},{2},{3},{4},{5},{6},{7},{8}""}}";

            var camMsg = string.Format(
                format,
                prevPos.x,
                prevPos.y,
                prevPos.z,
                lookAt.x,
                lookAt.y,
                lookAt.z,
                upVector.x,
                upVector.y,
                upVector.z);
#if !UNITY_EDITOR
            _webRtcControl.SendPeerDataChannelMessage(camMsg);
#endif
        }
        #endregion

        if (Time.time > endTime)
        {
            fpsCount   = (float)fpsCounter / (Time.time - startTime);
            fpsCounter = 0;
            endTime    = (startTime = Time.time) + 3;
        }

        MessageText.text = string.Format("Raw Frame: {0}\nFPS: {1}\n{2}", frameCounter, fpsCount, messageText);

#if !UNITY_EDITOR
        lock (_executionQueue)
        {
            while (!_executionQueue.IsEmpty)
            {
                Action qa;
                if (_executionQueue.TryDequeue(out qa))
                {
                    if (qa != null)
                    {
                        qa.Invoke();
                    }
                }
            }
        }
#endif
    }