コード例 #1
0
 public void AddController(SimpleCameraController controller)
 {
     m_listController.Add(controller);
     if (!controller.hasInputBeenSet)
     {
         print("Adding input to this controller");
         controller.SetInput(m_defaultInput);
     }
 }
コード例 #2
0
        void OnDataChannel(RTCPeerConnection pc, RTCDataChannel channel)
        {
            if (!m_mapPeerAndChannelDictionary.TryGetValue(pc, out var channels))
            {
                channels = new DataChannelDictionary();
                m_mapPeerAndChannelDictionary.Add(pc, channels);
            }
            channels.Add(channel.Id, channel);

            if (channel.Label != "data")
            {
                return;
            }

            RemoteInput input = RemoteInputReceiver.Create();

            input.ActionButtonClick = OnButtonClick;

            // device.current must be changed after creating devices
            m_defaultInput.MakeCurrent();

            m_mapChannelAndRemoteInput.Add(channel, input);
            channel.OnMessage = bytes => m_mapChannelAndRemoteInput[channel].ProcessInput(bytes);
            channel.OnClose   = () => OnCloseChannel(channel);

            // Instantiate prefab and create controller
            GameObject             gameObject = Instantiate(StreamingManager.Instance.playerPrefab, Vector3.zero, Quaternion.identity);
            SimpleCameraController controller = gameObject.GetComponentInChildren <SimpleCameraController>();

            if (controller != null)
            {
                print("SETTING INPUT FOR NEW CONTROLLER");
                controller.enabled = true;
                m_listController.Add(controller);
                controller.SetInput(input);
                m_remoteInputAndCameraController.Add(input, controller);

                byte   index = (byte)m_listController.IndexOf(controller);
                byte[] bytes = { (byte)UnityEventType.SwitchVideo, index };
                channel.Send(bytes);
            }
        }
コード例 #3
0
        void OnDataChannel(RTCPeerConnection pc, RTCDataChannel channel)
        {
            if (!m_mapPeerAndChannelDictionary.TryGetValue(pc, out var channels))
            {
                channels = new DataChannelDictionary();
                m_mapPeerAndChannelDictionary.Add(pc, channels);
            }

            channels.Add(channel.Id, channel);

            if (channel.Label != "data")
            {
                return;
            }

            RemoteInput input = RemoteInputReceiver.Create();

            input.ActionButtonClick = OnButtonClick;

            // device.current must be changed after creating devices
            m_defaultInput.MakeCurrent();

            m_mapChannelAndRemoteInput.Add(channel, input);
            channel.OnMessage = bytes => m_mapChannelAndRemoteInput[channel].ProcessInput(bytes);
            channel.OnClose   = () => OnCloseChannel(channel);

            // find controller that not assigned remote input
            SimpleCameraController controller = m_listController
                                                .FirstOrDefault(_controller => !m_remoteInputAndCameraController.ContainsValue(_controller));

            if (controller != null)
            {
                controller.SetInput(input);
                m_remoteInputAndCameraController.Add(input, controller);

                byte   index = (byte)m_listController.IndexOf(controller);
                byte[] bytes = { (byte)UnityEventType.SwitchVideo, index };
                channel.Send(bytes);
            }
        }
コード例 #4
0
 public void AddController(SimpleCameraController controller)
 {
     m_listController.Add(controller);
     controller.SetInput(m_defaultInput);
 }