void OnGUI() { if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI) { return; } VideoChat.framerate = framerate; bool oldTestMode = testMode; testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode"); if (testMode == false && oldTestMode == true) { VideoChat.ClearAudioOut(); } if (testMode) { GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold); audioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f); echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex)) { VideoChat.deviceIndex++; } GUI.color = Color.black; GUI.Label(new Rect(0, 120, Screen.width, Screen.height - 120), VideoChat.log); GUI.color = Color.white; VideoChat.testMode = testMode; return; }
void OnGUI() { if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI) { return; } VideoChat.framerate = framerate; if (!Network.isClient && !Network.isServer) { bool oldTestMode = testMode; testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode"); if (testMode == false && oldTestMode == true) { VideoChat.ClearAudioOut(); } if (testMode) { GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold); audioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f); echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } VideoChat.testMode = testMode; if (!testMode) { if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start")) { if (LAN) { LANParty.peerType = "server"; if (oneToManyBroadcast) { LANParty.possibleConnections = numberReceivers; } else { LANParty.possibleConnections = 1; } LANParty.log += "\n" + Network.InitializeServer(LANParty.possibleConnections, 2301, false); } else { if (oneToManyBroadcast) { Network.InitializeServer(numberReceivers, 2301, true); } else { Network.InitializeServer(1, 2301, true); } MasterServer.RegisterHost("MidnightVideoChat", "Test"); } } if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join")) { if (LAN) { LANParty.peerType = "client"; LANParty.Broadcast(LANParty.ipRequestString + LANParty.gameName); } else { if (hostData.Length == 0) { hostData = MasterServer.PollHostList(); } } StartCoroutine("DelayedConnection"); } } } else { if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect")) { StartCoroutine(Restart()); } GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold); currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f); if (!testMode) { if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time) { audioView.RPC("SetAudioThreshold", RPCMode.Others, currentAudioThreshold); audioThreshold = currentAudioThreshold; setAudioThresholdTimer = Time.time; } } if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex)) { VideoChat.deviceIndex++; } echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } return; }
void OnGUI() { return; // moved to Unity GUI, press buttons to call these methods. The actions are attached to the buttons on the scene, referencing the gameobject with this script. if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI) { return; } VideoChat.framerate = framerate; if (!Network.isClient && !Network.isServer) { bool oldTestMode = testMode; testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode"); if (testMode == false && oldTestMode == true) { VideoChat.ClearAudioOut(); } if (testMode) { GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold); audioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f); echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } VideoChat.testMode = testMode; if (!testMode) { if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start")) { StartVideoChat(); } if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join")) { JoinVideoChat(); } } } else { if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect")) { StartCoroutine(Restart()); } GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold); currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f); if (!testMode) { if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time) { audioView.RPC("SetAudioThreshold", RPCMode.Others, currentAudioThreshold); audioThreshold = currentAudioThreshold; setAudioThresholdTimer = Time.time; } } if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex)) { VideoChat.deviceIndex++; } echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } return; }
void OnGUI() { if (!VideoChat.tempImage && !VideoChat.setup || !UI) { return; } VideoChat.framerate = framerate; if (PhotonNetwork.room == null) { bool oldTestMode = testMode; testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode"); if (testMode == false && oldTestMode == true) { VideoChat.ClearAudioOut(); } if (testMode) { GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold); audioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f); echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } VideoChat.testMode = testMode; if (!testMode) { if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start")) { RoomOptions roomOptions = new RoomOptions(); if (oneToManyBroadcast) { roomOptions.maxPlayers = (byte)(numberReceivers + 1); } else { roomOptions.maxPlayers = 2; } roomOptions.cleanupCacheOnLeave = true; roomOptions.isVisible = true; roomOptions.isOpen = true; TypedLobby typedLobby = new TypedLobby(); typedLobby.Name = "chat"; typedLobby.Type = LobbyType.Default; PhotonNetwork.CreateRoom("MidnightVideoChat", roomOptions, typedLobby); PhotonNetwork.NetworkStatisticsEnabled = true; } if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join")) { PhotonNetwork.JoinRoom("MidnightVideoChat"); } } } else { if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect")) { Restart(); } GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold); currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f); if (!testMode) { if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time) { audioView.RPC("SetAudioThreshold", PhotonTargets.Others, currentAudioThreshold); audioThreshold = currentAudioThreshold; setAudioThresholdTimer = Time.time; } } echoCancel = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation"); echoCancellation = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off; VideoChat.echoCancellation = echoCancellation; } return; }