protected virtual void UpdateRecorderSprite() { PhotonVoiceRecorder recorder = this.GetComponent <HighlightIcon>().recorder; this.GetComponent <HighlightIcon>().recorderSprite.enabled = (recorder != null && recorder.IsTransmitting && PhotonVoiceNetwork.ClientState == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined); }
private void Awake() { photonView = GetComponent <PhotonView>(); voiceRecorder = GetComponent <PhotonVoiceRecorder>(); m_RigidBody = GetComponent <Rigidbody>(); m_Capsule = GetComponent <CapsuleCollider>(); if (photonView != null) { if (!photonView.isMine) { return; } } if (cam == null) { cam = Camera.main; HeadBob headBob = cam.GetComponent <HeadBob>(); headBob.Init(cam, cameraPos, this, photonView); } mouseLook.Init(transform, cam.transform); }
void Awake() { m_NetVocie = FindObjectOfType <NetVoice>(); m_PhotonView = GetComponent <PhotonView>(); m_VoiceRecorder = GetComponent <PhotonVoiceRecorder>(); m_VoiceSpeaker = GetComponent <PhotonVoiceSpeaker>(); }
void Start() { s_tag = Util.S_ENEMY; Main_Bullet = Resources.Load("BulletPrefab/" + Util.S_GATLING_BULLET_NAME) as GameObject; Sub_Bullet = Resources.Load("BulletPrefab/" + Util.S_GRENADE_BULLET_NAME) as GameObject; Weapon1 = new GeneralInitialize.GunParameter(Util.S_GATLING_NAME, Util.S_GATLING_BULLET_NAME, Util.F_GATLING_BULLET_SPEED, Util.F_GATLING_BULLET_DAMAGE, Util.F_GATLING_MAGAZINE); Weapon2 = new GeneralInitialize.GunParameter(Util.S_GRENADE_NAME, Util.S_GRENADE_BULLET_NAME, Util.F_GRENADE_BULLET_SPEED, Util.F_GRENADE_BULLET_DAMAGE, Util.F_GRENADE_MAGAZINE); InitializeParam(); cur_Weapon = Weapon1; Muzzle = Muzzle1; spine_GunAnim.Skeleton.SetSkin(Weapon1.s_GunName); if (UI != null) { GameObject _uiGo = Instantiate(UI) as GameObject; _uiGo.SendMessage("SetTarget", this, SendMessageOptions.RequireReceiver); } else { Debug.LogWarning("<Color=Red><a>Missing</a></Color> PlayerUiPrefab reference on player Prefab.", this); } PhotonNetwork.sendRate = 500 / Launcher.MaxPlayersPerRoom; PhotonNetwork.sendRateOnSerialize = 500 / Launcher.MaxPlayersPerRoom; // Find Photon Voice Recorder And Speaker recorder = this.GetComponent <PhotonVoiceRecorder>(); speaker = this.GetComponent <PhotonVoiceSpeaker>(); }
public override void OnInspectorGUI() { PhotonVoiceRecorder rec = target as PhotonVoiceRecorder; rec.Source = (PhotonVoiceRecorder.AudioSource)EditorGUILayout.EnumPopup("Source", rec.Source); rec.TypeConvert = (PhotonVoiceRecorder.SampleTypeConv)EditorGUILayout.EnumPopup("Type Convert", rec.TypeConvert); switch (rec.Source) { case PhotonVoiceRecorder.AudioSource.Microphone: rec.MicrophoneType = (PhotonVoiceRecorder.MicAudioSourceType)EditorGUILayout.EnumPopup("Microphone Type", rec.MicrophoneType); break; case PhotonVoiceRecorder.AudioSource.AudioClip: rec.AudioClip = EditorGUILayout.ObjectField("Audio Clip", rec.AudioClip, typeof(AudioClip), true) as AudioClip; rec.LoopAudioClip = EditorGUILayout.Toggle("Loop Audio Clip", rec.LoopAudioClip); break; case PhotonVoiceRecorder.AudioSource.Factory: break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary>This is a callback by PUN. Makes sure recording is off when leaving the room.</summary> /// <remarks>Unlike callbacks from the Voice Client, this only updates you on the state of PUN. Use to control voice according to changes in PUN.</remarks> public void OnLeftRoom() { if (rec != null) { rec.enabled = false; rec = null; } }
/// <summary> /// A callback for CharacterInstantiation. We need the PhotonVoiceRecorder from our new character. /// </summary> /// <param name="character">This client's character.</param> private void CharacterInstantiation_CharacterInstantiated(GameObject character) { rec = character.GetComponent <PhotonVoiceRecorder>(); if (rec != null) { rec.enabled = true; } }
private void Awake() { //Remember that this script is attached to a child object of the player. //This child object should only need a PhotonView with no observed components and default values, //and a PhotonVoiceRecorder which will also add a PhotonVoiceSpeaker and AudioSource. view = GetComponent <PhotonView>(); mic = GetComponent <PhotonVoiceRecorder>(); }
private void OnEnable() { _photonView = GetComponent <PhotonView>(); _photonVoiceRecorder = GetComponent <PhotonVoiceRecorder>(); _photonVoiceSpeaker = GetComponent <PhotonVoiceSpeaker>(); VoiceClient.RegisterVoicePlayer(_photonView.ownerId, this); SetVolume(); }
IEnumerator DelayedAvatarInstantiation(object content, int senderid) { yield return(new WaitForSecondsRealtime(0.1f)); object[] instantiationData = (object[])content; //Create panel PhotonPlayer photonPlayer = PhotonPlayer.Find(senderid); GameObject go = null; int viewId = (int)instantiationData[0]; string oculusId = (string)instantiationData[1]; if (PhotonNetwork.player.ID == senderid) { go = Instantiate(m_LocalAvatarPrefab); m_PlayerAvatars.Add(photonPlayer.ID, go); _LocalAvatar = go; _LocalVoiceRecorder = PhotonNetwork.Instantiate("PhotonPlayerVoice", Vector3.zero, Quaternion.identity, 0).GetComponent <PhotonVoiceRecorder>(); _LocalVoiceRecorder.transform.SetParent(go.transform); _LocalAvatar.transform.SetParent(CameraController.CameraContainer.transform); } else { go = Instantiate(m_RemoteAvatarPrefab); m_PlayerAvatars.Add(photonPlayer.ID, go); } if (go != null) { PhotonView pView = go.GetComponent <PhotonView>(); if (pView != null) { pView.viewID = viewId; pView.ownerId = senderid; } OvrAvatar avatar = go.GetComponent <OvrAvatar>(); avatar.oculusUserID = oculusId; if (photonPlayer.IsLocal) { Fader.FadeInAll(); } m_PositionController.SetObjectPosition(go, (UserPosition)photonPlayer.CustomProperties["EnvironmentLocation"], (int)photonPlayer.CustomProperties["EnvironmentPositionIndex"]); if (!photonPlayer.IsLocal) { SetPlayerPosition(photonPlayer); } } }
float[] GetLocalVoiceBuffer() { PhotonVoiceRecorder pvn = GetComponent <PhotonVoiceRecorder>(); System.Reflection.FieldInfo voiceFieldInfo = typeof(PhotonVoiceRecorder).GetField("voice", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); LocalVoice localVoice = (LocalVoice)voiceFieldInfo.GetValue(pvn); System.Reflection.FieldInfo bufferFieldInfo = typeof(LocalVoice).GetField("sourceFrameBuffer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); return((float[])bufferFieldInfo.GetValue(localVoice)); }
// Initialize void Start() { // Get components used by Photon Voice audioSource = GetComponent <AudioSource>(); voiceRecorder = GetComponent <PhotonVoiceRecorder>(); EventManager.registerListener("voiceEnable", startTransmitting); EventManager.registerListener("voiceDisable", stopTransmitting); EventManager.registerListener("voiceOff", disableVoiceChat); EventManager.registerListener("voiceOn", enableVoiceChat); }
// Use this for initialization IEnumerator Start() { while (FindObjectOfType <ReadyManager>().localPlayer == null) { yield return(null); } settings = FindObjectOfType <PhotonVoiceSettings>(); rec = FindObjectOfType <ReadyManager>().localPlayer.GetComponent <PhotonVoiceRecorder>(); PhotonVoiceNetwork.Client.ChangeAudioGroups(new byte[0], null); rec.AudioGroup = (byte)0; }
// Use this for initialization void Start() { _target = transform.parent.gameObject; recorder = _target.GetComponent <PhotonVoiceRecorder> (); speaker = _target.GetComponent <PhotonVoiceSpeaker> (); object playerType; manager = _target.GetComponent <CameraRigManager> (); manager.photonView.owner.CustomProperties.TryGetValue("playerType", out playerType); UpdateText(playerType.ToString() + " : " + manager.photonView.owner.NickName); ResetUI(); }
// Use this for initialization void Start() { Cursor.lockState = CursorLockMode.Locked; //Disable voice chat voiceChat = GetComponent <PhotonVoiceRecorder>(); voiceChat.Transmit = false; // For capsule cast system cam = Camera.main.transform; middle = GameObject.FindGameObjectWithTag("middle"); instructionPanel.SetActive(false); teamOrders = new List <Order>(); enemyOrders = new List <Order>(); indicators = GameObject.FindGameObjectsWithTag("Indicators"); // IF this is the object belong to the controlled clident, enable for the client to control if (photonView.isMine) { GetComponent <BasicBehaviour>().enabled = true; GetComponent <MoveBehaviour>().enabled = true; GetComponent <AudioListener>().enabled = true; Invoke("getAllPlayers", 1); //cookbookShowHide(true); //cookbookShowHide(false); cookbookControl = cookBook.GetComponent <cookbook_controller>(); } else //IF not, disable { GetComponent <BasicBehaviour>().enabled = false; GetComponent <MoveBehaviour>().enabled = false; GetComponent <AudioListener>().enabled = false; //Disbale all children objects not belong to mine foreach (Transform child in transform) { if (child.tag == "notLocal") { child.gameObject.SetActive(false); } } } hitObject = this.gameObject; GameCount = 605; countdownText.color = Color.yellow; ScoreSelf.text = "0"; ScoreEnemy.text = "0"; //cursorAppear(); pickup_bg.enabled = false; }
public VoiceClient() { PhotonVoiceSettings.Instance.VoiceDetection = false; PhotonVoiceSettings.Instance.AutoTransmit = false; PhotonVoiceSettings.Instance.AutoDisconnect = true; PhotonVoiceSettings.Instance.AutoConnect = true; _gameObject = PhotonNetwork.Instantiate(VoicePlayerPath, Vector3.zero, Quaternion.identity, 0); SetVolume(); _rec = _gameObject.GetComponent <PhotonVoiceRecorder>(); _rec.enabled = true; }
// Use this for initialization void Start() { recorder = this.transform.parent.GetComponent <PhotonVoiceRecorder>(); if (recorder == null) { this.enabled = false; return; } rendererComp = this.GetComponent <Renderer>(); if (rendererComp == null) { this.enabled = false; return; } }
public override void OnJoinedRoom() { var punVoice = GameObject.Instantiate(PUNVoice); _voiceRecorder = punVoice.GetComponent <PhotonVoiceRecorder>(); int viewId = PhotonNetwork.AllocateViewID(); var data = new Dictionary <string, object> { { "ViewID", viewId }, { "Position", LocalPlayer.transform.position } }; RaiseEvent(EventCode.InstantiateVRAvatar, data); }
public override void OnJoinedRoom() { base.OnJoinedRoom(); if (string.IsNullOrEmpty(m_VoiceInstancePrefabName)) { Debug.LogError("预制语音实例为空,无法生成语音实例!"); return; } m_LocalVoiceInstance = PhotonNetwork.Instantiate(m_VoiceInstancePrefabName, Vector3.zero, Quaternion.identity, 0); // todo : parenting of other players voice instance m_LocalVoiceInstance.transform.SetParent(transform); PhotonVoiceRecorder recorder = m_LocalVoiceInstance.GetComponent <PhotonVoiceRecorder>(); recorder.Transmit = false; recorder.MicrophoneDevice = m_Microphone; onPhotonEvent.Invoke(Timestamp.ImprintLocalTime() + "已加入房间语音信道" + (m_Microphone == null ? ",当前无可用麦克风。" : ",当前麦克风" + m_Microphone)); //recorder.VoiceDetectorCalibrate(CALIBRATION_DURATION_MS); }
private Quaternion correctAvatarRot = Quaternion.identity; //We lerp towards this void Update() { PhotonVoiceRecorder photonVoiceRecorder = GetComponent <PhotonVoiceRecorder>(); if (!photonView.isMine) { //Update remote player (smooth this, this looks good, at the cost of some accuracy) avatar.transform.localPosition = Vector3.Lerp(avatar.transform.localPosition, correctAvatarPos, Time.deltaTime * 5); avatar.transform.localRotation = Quaternion.Lerp(avatar.transform.localRotation, correctAvatarRot, Time.deltaTime * 5); photonVoiceRecorder.Transmit = true; photonVoiceRecorder.UpdateAudioSource(); Debug.Log("Is Transmit other: " + photonVoiceRecorder.IsTransmitting); Debug.Log("Is Play other: " + GetComponent <PhotonVoiceSpeaker>().IsPlaying); } else { Debug.Log("Is Transmit me: " + photonVoiceRecorder.IsTransmitting); Debug.Log("Is Play me: " + GetComponent <PhotonVoiceSpeaker>().IsPlaying); if (Input.GetKey(KeyCode.D)) { avatar.transform.Translate(Vector3.right * Time.deltaTime * 3f); } if (Input.GetKey(KeyCode.A)) { avatar.transform.Translate(Vector3.left * Time.deltaTime * 3f); } if (Input.GetKey(KeyCode.S)) { avatar.transform.Translate(Vector3.back * Time.deltaTime * 3f); } if (Input.GetKey(KeyCode.W)) { avatar.transform.Translate(Vector3.forward * Time.deltaTime * 3f); } } }
// Update is called once per frame void OnGUI() { // TODO: better way to ref recorder PhotonVoiceRecorder rec = null; foreach (var r in FindObjectsOfType <PhotonVoiceRecorder>()) { if (r.photonView.isMine) { rec = r; break; } } var lStyle = new GUIStyle("label"); lStyle.fontSize = 24 * Screen.height / 600; lStyle.wordWrap = false; var lStyleSmall = new GUIStyle("label"); lStyleSmall.fontSize = 16 * Screen.height / 600; lStyleSmall.wordWrap = false; var bStyle = new GUIStyle("button"); bStyle.fontSize = 28 * Screen.height / 600; var bStyleSmall = new GUIStyle("button"); bStyleSmall.fontSize = 16 * Screen.height / 600; var roomName = ""; if (PhotonNetwork.inRoom) { roomName = PhotonNetwork.room.Name; } string rttString = String.Format( "RTT/Var/Que: {0}/{1}/{2}", PhotonNetwork.networkingPeer.RoundTripTime.ToString(), PhotonNetwork.networkingPeer.RoundTripTimeVariance, PhotonNetwork.networkingPeer.QueuedIncomingCommands); GUILayout.Label("PUN: " + PhotonNetwork.connectionStateDetailed.ToString() + " " + roomName + " " + rttString, lStyle); GUILayout.BeginHorizontal(); if (GUILayout.Button("Connect", bStyle)) { #if UNITY_5_3_OR_NEWER PhotonNetwork.ConnectUsingSettings(string.Format("1.{0}", UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex)); #else PhotonNetwork.ConnectUsingSettings(string.Format("1.{0}", Application.loadedLevel)); #endif } if (GUILayout.Button("Disconnect", bStyle)) { PhotonNetwork.Disconnect(); } GUILayout.EndHorizontal(); roomName = ""; if (PhotonVoiceNetwork.ClientState == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined) { roomName = PhotonVoiceNetwork.CurrentRoomName; } if (dataRateNextTime < Time.time) { dataRateNextTime = Time.time + 1; dataRateIn = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes - prevInBytes) / 1; dataRateOut = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes - prevOutBytes) / 1; prevInBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes; prevOutBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes; } rttString = String.Format( "RTT/Var/Que: {0}/{1}/{2}", PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTime.ToString(), PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTimeVariance, PhotonVoiceNetwork.Client.loadBalancingPeer.QueuedIncomingCommands); GUILayout.Label("PhotonVoice: " + PhotonVoiceNetwork.ClientState.ToString() + " " + roomName + " " + rttString, lStyle); GUILayout.BeginHorizontal(); GUILayout.Label("Data rate in/out bytes/sec: " + dataRateIn + "/" + dataRateOut, lStyleSmall); if (PhotonVoiceNetwork.Client.loadBalancingPeer != null) { GUILayout.Label("Traffic bytes: " + PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes + "/" + PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes, lStyleSmall); } GUILayout.Label("Frames Sent/Rcvd/Lost: " + PhotonVoiceNetwork.VoiceClient.FramesSent + "/" + PhotonVoiceNetwork.VoiceClient.FramesReceived + "/" + PhotonVoiceNetwork.VoiceClient.FramesLost, lStyleSmall); GUILayout.Label("Voice RTT/Var: " + PhotonVoiceNetwork.VoiceClient.RoundTripTime + "/" + PhotonVoiceNetwork.VoiceClient.RoundTripTimeVariance, lStyleSmall); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Speakers:", lStyleSmall); foreach (var s in FindObjectsOfType <PhotonVoiceSpeaker>()) { if (s.IsVoiceLinked) { GUILayout.Label("lag=" + s.CurrentBufferLag, lStyleSmall); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Connect", bStyle)) { PhotonVoiceNetwork.Connect(); } if (GUILayout.Button("Disconnect", bStyle)) { PhotonVoiceNetwork.Disconnect(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (rec != null && rec.photonView.isMine) { if (GUILayout.Button((rec.DebugEchoMode ? "[X] " : "[ ] ") + "Debug Echo", bStyle)) { rec.DebugEchoMode = !rec.DebugEchoMode; } if (GUILayout.Button((rec.Transmit ? "[X] ": "[ ] ") + "Transmit", bStyle)) { rec.Transmit = !rec.Transmit; } if (GUILayout.Button((rec.VoiceDetector.On ? "[X] " : "[ ] ") + "Detect", bStyle)) { rec.Detect = !rec.Detect; } if (GUILayout.Button((rec.VoiceDetectorCalibrating ? "[X] " : "[ ] ") + "Calibrate Detector", bStyle)) { rec.VoiceDetectorCalibrate(2000); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Transmitting: " + rec.IsTransmitting, lStyleSmall); GUILayout.Label("Avg Amp: " + (rec.LevelMeter == null ? "" : rec.LevelMeter.CurrentAvgAmp.ToString("0.000000") + "/" + rec.LevelMeter.AccumAvgPeakAmp.ToString("0.000000")), lStyleSmall); GUILayout.Label("Peak Amp: " + (rec.LevelMeter == null ? "" : rec.LevelMeter.CurrentPeakAmp.ToString("0.000000")), lStyleSmall); GUILayout.Label("Detector Threshold: " + (rec.VoiceDetector == null ? "" : rec.VoiceDetector.Threshold.ToString("0.000000")), lStyleSmall); GUILayout.Label("Audio group (rec): " + rec.AudioGroup.ToString(), lStyleSmall); GUILayout.EndHorizontal(); } else { GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("Set Group (offs Debug Echo): ", lStyleSmall); for (byte i = 0; i < 5; i++) { if (GUILayout.Button((PhotonVoiceNetwork.Client.GlobalAudioGroup == i ? "[X] " : "[ ] ") + (i == 0 ? "No" : i.ToString()), bStyleSmall)) { PhotonVoiceNetwork.Client.GlobalAudioGroup = i; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Mic: ", lStyleSmall); foreach (var x in Microphone.devices) { if (GUILayout.Button((PhotonVoiceNetwork.MicrophoneDevice == x ? "[X] " : "[ ] ") + x, bStyleSmall)) { PhotonVoiceNetwork.MicrophoneDevice = x; } } GUILayout.EndHorizontal(); GUI.enabled = true; }
private void Awake() { photonView = GetComponent <PhotonView>(); voiceRecorder = GetComponent <PhotonVoiceRecorder>(); }
private void Update() { // editor only two-ways binding for toggles #if UNITY_EDITOR InitToggles(globalSettingsToggles); #endif switch (PhotonNetwork.connectionStateDetailed) { case ClientState.PeerCreated: case ClientState.Disconnected: punSwitch.interactable = true; punSwitchText.text = "PUN Connect"; if (rec != null) { rec.enabled = false; rec = null; } break; case ClientState.Joined: punSwitch.interactable = true; punSwitchText.text = "PUN Disconnect"; break; default: punSwitch.interactable = false; punSwitchText.text = "PUN busy"; break; } switch (PhotonVoiceNetwork.ClientState) { case Client.Photon.LoadBalancing.ClientState.Joined: voiceSwitch.interactable = true; voiceSwitchText.text = "Voice Disconnect"; inGameSettings.SetActive(true); InitToggles(inGameSettings.GetComponentsInChildren <Toggle>()); if (rec != null) { calibrateButton.interactable = !rec.VoiceDetectorCalibrating; calibrateText.text = rec.VoiceDetectorCalibrating ? "Calibrating" : string.Format("Calibrate ({0}s)", calibrationMilliSeconds / 1000); } else { calibrateButton.interactable = false; calibrateText.text = "Unavailable"; } break; case Client.Photon.LoadBalancing.ClientState.Uninitialized: case Client.Photon.LoadBalancing.ClientState.Disconnected: if (PhotonNetwork.inRoom) { voiceSwitch.interactable = true; voiceSwitchText.text = "Voice Connect"; voiceDebugText.text = ""; } else { voiceSwitch.interactable = false; voiceSwitchText.text = "Voice N/A"; voiceDebugText.text = ""; } calibrateButton.interactable = false; calibrateText.text = "Unavailable"; inGameSettings.SetActive(false); break; default: voiceSwitch.interactable = false; voiceSwitchText.text = "Voice busy"; break; } if (debugMode) { punState.text = string.Format("PUN: {0}", PhotonNetwork.connectionStateDetailed); voiceState.text = string.Format("PhotonVoice: {0}", PhotonVoiceNetwork.ClientState); if (rec != null && rec.LevelMeter != null) { voiceDebugText.text = string.Format("Amp: avg. {0}, peak {1}", rec.LevelMeter.CurrentAvgAmp.ToString("0.000000"), rec.LevelMeter.CurrentPeakAmp.ToString("0.000000")); } } }
private void Awake() { PhotonView = GetComponent <PhotonView>(); PhotonVoiceSettings.Instance.AutoTransmit = false; PhotonVoiceRecorder = GetComponent <PhotonVoiceRecorder>(); }
// Use this for initialization void Start() { rec = GetComponent <PhotonVoiceRecorder> (); rec.Transmit = false; }
// Token: 0x06000092 RID: 146 RVA: 0x000043F4 File Offset: 0x000025F4 private void OnGUI() { PhotonVoiceRecorder photonVoiceRecorder = null; foreach (PhotonVoiceRecorder photonVoiceRecorder2 in Object.FindObjectsOfType <PhotonVoiceRecorder>()) { if (photonVoiceRecorder2.photonView.isMine) { photonVoiceRecorder = photonVoiceRecorder2; break; } } GUIStyle guistyle = new GUIStyle("label"); guistyle.fontSize = 24 * Screen.height / 600; guistyle.wordWrap = false; GUIStyle guistyle2 = new GUIStyle("label"); guistyle2.fontSize = 16 * Screen.height / 600; guistyle2.wordWrap = false; GUIStyle guistyle3 = new GUIStyle("button"); guistyle3.fontSize = 28 * Screen.height / 600; GUIStyle guistyle4 = new GUIStyle("button"); guistyle4.fontSize = 16 * Screen.height / 600; string text = ""; if (PhotonNetwork.inRoom) { text = PhotonNetwork.room.Name; } string text2 = string.Format("RTT/Var/Que: {0}/{1}/{2}", PhotonNetwork.networkingPeer.RoundTripTime.ToString(), PhotonNetwork.networkingPeer.RoundTripTimeVariance, PhotonNetwork.networkingPeer.QueuedIncomingCommands); GUILayout.Label(string.Concat(new string[] { "PUN: ", PhotonNetwork.connectionStateDetailed.ToString(), " ", text, " ", text2 }), guistyle, Array.Empty <GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); if (GUILayout.Button("Connect", guistyle3, Array.Empty <GUILayoutOption>())) { PhotonNetwork.ConnectUsingSettings(string.Format("1.{0}", SceneManagerHelper.ActiveSceneBuildIndex)); } if (GUILayout.Button("Disconnect", guistyle3, Array.Empty <GUILayoutOption>())) { PhotonNetwork.Disconnect(); } GUILayout.EndHorizontal(); text = ""; if (PhotonVoiceNetwork.ClientState == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined) { text = PhotonVoiceNetwork.CurrentRoomName; } if (this.dataRateNextTime < Time.time) { this.dataRateNextTime = Time.time + 1f; this.dataRateIn = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes - this.prevInBytes) / 1; this.dataRateOut = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes - this.prevOutBytes) / 1; this.prevInBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes; this.prevOutBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes; } text2 = string.Format("RTT/Var/Que: {0}/{1}/{2}", PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTime.ToString(), PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTimeVariance, PhotonVoiceNetwork.Client.loadBalancingPeer.QueuedIncomingCommands); GUILayout.Label(string.Concat(new string[] { "PhotonVoice: ", PhotonVoiceNetwork.ClientState.ToString(), " ", text, " ", text2 }), guistyle, Array.Empty <GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label(string.Concat(new object[] { "Data rate in/out bytes/sec: ", this.dataRateIn, "/", this.dataRateOut }), guistyle2, Array.Empty <GUILayoutOption>()); if (PhotonVoiceNetwork.Client.loadBalancingPeer != null) { GUILayout.Label(string.Concat(new object[] { "Traffic bytes: ", PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes, "/", PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes }), guistyle2, Array.Empty <GUILayoutOption>()); } GUILayout.Label(string.Concat(new object[] { "Frames Sent/Rcvd/Lost: ", PhotonVoiceNetwork.VoiceClient.FramesSent, "/", PhotonVoiceNetwork.VoiceClient.FramesReceived, "/", PhotonVoiceNetwork.VoiceClient.FramesLost }), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.Label(string.Concat(new object[] { "Voice RTT/Var: ", PhotonVoiceNetwork.VoiceClient.RoundTripTime, "/", PhotonVoiceNetwork.VoiceClient.RoundTripTimeVariance }), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Speakers:", guistyle2, Array.Empty <GUILayoutOption>()); foreach (PhotonVoiceSpeaker photonVoiceSpeaker in Object.FindObjectsOfType <PhotonVoiceSpeaker>()) { if (photonVoiceSpeaker.IsVoiceLinked) { GUILayout.Label("lag=" + photonVoiceSpeaker.CurrentBufferLag, guistyle2, Array.Empty <GUILayoutOption>()); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); if (GUILayout.Button("Connect", guistyle3, Array.Empty <GUILayoutOption>())) { PhotonVoiceNetwork.Connect(); } if (GUILayout.Button("Disconnect", guistyle3, Array.Empty <GUILayoutOption>())) { PhotonVoiceNetwork.Disconnect(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); if (photonVoiceRecorder != null && photonVoiceRecorder.photonView.isMine) { if (GUILayout.Button((photonVoiceRecorder.DebugEchoMode ? "[X] " : "[ ] ") + "Debug Echo", guistyle3, Array.Empty <GUILayoutOption>())) { photonVoiceRecorder.DebugEchoMode = !photonVoiceRecorder.DebugEchoMode; } if (GUILayout.Button((photonVoiceRecorder.Transmit ? "[X] " : "[ ] ") + "Transmit", guistyle3, Array.Empty <GUILayoutOption>())) { photonVoiceRecorder.Transmit = !photonVoiceRecorder.Transmit; } if (GUILayout.Button((photonVoiceRecorder.VoiceDetector.On ? "[X] " : "[ ] ") + "Detect", guistyle3, Array.Empty <GUILayoutOption>())) { photonVoiceRecorder.Detect = !photonVoiceRecorder.Detect; } if (GUILayout.Button((photonVoiceRecorder.VoiceDetectorCalibrating ? "[X] " : "[ ] ") + "Calibrate Detector", guistyle3, Array.Empty <GUILayoutOption>())) { photonVoiceRecorder.VoiceDetectorCalibrate(2000); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Transmitting: " + photonVoiceRecorder.IsTransmitting.ToString(), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.Label("Avg Amp: " + ((photonVoiceRecorder.LevelMeter == null) ? "" : (photonVoiceRecorder.LevelMeter.CurrentAvgAmp.ToString("0.000000") + "/" + photonVoiceRecorder.LevelMeter.AccumAvgPeakAmp.ToString("0.000000"))), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.Label("Peak Amp: " + ((photonVoiceRecorder.LevelMeter == null) ? "" : photonVoiceRecorder.LevelMeter.CurrentPeakAmp.ToString("0.000000")), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.Label("Detector Threshold: " + ((photonVoiceRecorder.VoiceDetector == null) ? "" : photonVoiceRecorder.VoiceDetector.Threshold.ToString("0.000000")), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.Label("Audio group (rec): " + photonVoiceRecorder.AudioGroup.ToString(), guistyle2, Array.Empty <GUILayoutOption>()); GUILayout.EndHorizontal(); } else { GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Set Group (offs Debug Echo): ", guistyle2, Array.Empty <GUILayoutOption>()); for (byte b = 0; b < 5; b += 1) { if (GUILayout.Button(((PhotonVoiceNetwork.Client.GlobalAudioGroup == b) ? "[X] " : "[ ] ") + ((b == 0) ? "No" : b.ToString()), guistyle4, Array.Empty <GUILayoutOption>())) { PhotonVoiceNetwork.Client.GlobalAudioGroup = b; } } GUILayout.EndHorizontal(); PhotonVoiceSettings instance = PhotonVoiceSettings.Instance; GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Unity Mic: ", guistyle2, Array.Empty <GUILayoutOption>()); foreach (string text3 in Microphone.devices) { if (GUILayout.Button(((instance.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Unity && PhotonVoiceNetwork.MicrophoneDevice == text3) ? "[X] " : "[ ] ") + text3, guistyle4, Array.Empty <GUILayoutOption>())) { instance.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Unity; PhotonVoiceNetwork.MicrophoneDevice = text3; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Label("Photon Mic: ", guistyle2, Array.Empty <GUILayoutOption>()); if (PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IsSupported) { for (int j = 0; j < PhotonVoiceNetwork.PhotonMicrophoneEnumerator.Count; j++) { if (GUILayout.Button(((instance.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Photon && PhotonVoiceNetwork.PhotonMicrophoneDeviceID == PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IDAtIndex(j)) ? "[X] " : "[ ] ") + PhotonVoiceNetwork.PhotonMicrophoneEnumerator.NameAtIndex(j), guistyle4, Array.Empty <GUILayoutOption>())) { instance.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Photon; PhotonVoiceNetwork.PhotonMicrophoneDeviceID = PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IDAtIndex(j); } } if (GUILayout.Button("Refresh", guistyle4, Array.Empty <GUILayoutOption>())) { PhotonVoiceNetwork.PhotonMicrophoneEnumerator.Refresh(); } } else if (Microphone.devices.Length != 0 && GUILayout.Button(((instance.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Photon) ? "[X] " : "[ ] ") + Microphone.devices[0], guistyle4, Array.Empty <GUILayoutOption>())) { instance.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Photon; PhotonVoiceNetwork.PhotonMicrophoneDeviceID = -1; } GUILayout.EndHorizontal(); GUI.enabled = true; }
// Update is called once per frame void OnGUI() { // TODO: better way to ref recorder PhotonVoiceRecorder rec = null; foreach (var r in FindObjectsOfType <PhotonVoiceRecorder>()) { if (r.photonView.isMine) { rec = r; break; } } var lStyle = new GUIStyle("label"); lStyle.fontSize = 24 * Screen.height / 600; lStyle.wordWrap = false; var lStyleSmall = new GUIStyle("label"); lStyleSmall.fontSize = 16 * Screen.height / 600; lStyleSmall.wordWrap = false; var bStyle = new GUIStyle("button"); bStyle.fontSize = 28 * Screen.height / 600; var bStyleSmall = new GUIStyle("button"); bStyleSmall.fontSize = 16 * Screen.height / 600; var roomName = ""; if (PhotonNetwork.inRoom) { roomName = PhotonNetwork.room.Name; } string rttString = String.Format( "RTT/Var/Que: {0}/{1}/{2}", PhotonNetwork.networkingPeer.RoundTripTime.ToString(), PhotonNetwork.networkingPeer.RoundTripTimeVariance, PhotonNetwork.networkingPeer.QueuedIncomingCommands); GUILayout.Label("PUN: " + PhotonNetwork.connectionStateDetailed.ToString() + " " + roomName + " " + rttString, lStyle); GUILayout.BeginHorizontal(); if (GUILayout.Button("Connect", bStyle)) { PhotonNetwork.ConnectUsingSettings(string.Format("1.{0}", SceneManagerHelper.ActiveSceneBuildIndex)); } if (GUILayout.Button("Disconnect", bStyle)) { PhotonNetwork.Disconnect(); } GUILayout.EndHorizontal(); roomName = ""; if (PhotonVoiceNetwork.ClientState == ExitGames.Client.Photon.LoadBalancing.ClientState.Joined) { roomName = PhotonVoiceNetwork.CurrentRoomName; } if (dataRateNextTime < Time.time) { dataRateNextTime = Time.time + 1; dataRateIn = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes - prevInBytes) / 1; dataRateOut = (PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes - prevOutBytes) / 1; prevInBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes; prevOutBytes = PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes; } rttString = String.Format( "RTT/Var/Que: {0}/{1}/{2}", PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTime.ToString(), PhotonVoiceNetwork.Client.loadBalancingPeer.RoundTripTimeVariance, PhotonVoiceNetwork.Client.loadBalancingPeer.QueuedIncomingCommands); GUILayout.Label("PhotonVoice: " + PhotonVoiceNetwork.ClientState.ToString() + " " + roomName + " " + rttString, lStyle); GUILayout.BeginHorizontal(); GUILayout.Label("Data rate in/out bytes/sec: " + dataRateIn + "/" + dataRateOut, lStyleSmall); if (PhotonVoiceNetwork.Client.loadBalancingPeer != null) { GUILayout.Label("Traffic bytes: " + PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsIncoming.TotalPacketBytes + "/" + PhotonVoiceNetwork.Client.loadBalancingPeer.TrafficStatsOutgoing.TotalPacketBytes, lStyleSmall); } GUILayout.Label("Frames Sent/Rcvd/Lost: " + PhotonVoiceNetwork.VoiceClient.FramesSent + "/" + PhotonVoiceNetwork.VoiceClient.FramesReceived + "/" + PhotonVoiceNetwork.VoiceClient.FramesLost, lStyleSmall); GUILayout.Label("Voice RTT/Var: " + PhotonVoiceNetwork.VoiceClient.RoundTripTime + "/" + PhotonVoiceNetwork.VoiceClient.RoundTripTimeVariance, lStyleSmall); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Speakers:", lStyleSmall); foreach (var s in FindObjectsOfType <PhotonVoiceSpeaker>()) { if (s.IsVoiceLinked) { GUILayout.Label("lag=" + s.CurrentBufferLag, lStyleSmall); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Connect", bStyle)) { PhotonVoiceNetwork.Connect(); } if (GUILayout.Button("Disconnect", bStyle)) { PhotonVoiceNetwork.Disconnect(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (rec != null && rec.photonView.isMine) { if (GUILayout.Button((rec.DebugEchoMode ? "[X] " : "[ ] ") + "Debug Echo", bStyle)) { rec.DebugEchoMode = !rec.DebugEchoMode; } if (GUILayout.Button((rec.Transmit ? "[X] ": "[ ] ") + "Transmit", bStyle)) { rec.Transmit = !rec.Transmit; } if (GUILayout.Button((rec.VoiceDetector.On ? "[X] " : "[ ] ") + "Detect", bStyle)) { rec.Detect = !rec.Detect; } if (GUILayout.Button((rec.VoiceDetectorCalibrating ? "[X] " : "[ ] ") + "Calibrate Detector", bStyle)) { rec.VoiceDetectorCalibrate(2000); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Transmitting: " + rec.IsTransmitting, lStyleSmall); GUILayout.Label("Avg Amp: " + (rec.LevelMeter == null ? "" : rec.LevelMeter.CurrentAvgAmp.ToString("0.000000") + "/" + rec.LevelMeter.AccumAvgPeakAmp.ToString("0.000000")), lStyleSmall); GUILayout.Label("Peak Amp: " + (rec.LevelMeter == null ? "" : rec.LevelMeter.CurrentPeakAmp.ToString("0.000000")), lStyleSmall); GUILayout.Label("Detector Threshold: " + (rec.VoiceDetector == null ? "" : rec.VoiceDetector.Threshold.ToString("0.000000")), lStyleSmall); GUILayout.Label("Audio group (rec): " + rec.AudioGroup.ToString(), lStyleSmall); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); var speexDSP = rec.GetComponent <SpeexDSP>(); if (speexDSP != null) { if (GUILayout.Button((speexDSP.AEC ? "[X] AEC" : "[ ] AEC"), bStyle)) { speexDSP.AEC = !speexDSP.AEC; } if (GUILayout.Button("Reset", bStyle)) { speexDSP.ResetAEC(); } GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); GUILayout.Label("delay:", lStyle); var x = speexDSP.AECPlaybackDelayMs.ToString(); var tStyle = new GUIStyle("textfield"); tStyle.fontSize = bStyle.fontSize; speexDSP.AECPlaybackDelayMs = Int32.Parse(GUILayout.TextField(x, tStyle)); GUILayout.EndHorizontal(); if (GUILayout.Button((speexDSP.AECLatencyDetect ? "[X] Latency Detect:" : "[ ] Latency Detect"), bStyle)) { speexDSP.AECLatencyDetect = !speexDSP.AECLatencyDetect; } if (speexDSP.AECLatencyDetect) { var l = speexDSP.Processor.AECLatencyResult; GUILayout.Label(l.LatencyMs + "/" + l.LatencyDelayedMs + " ms", lStyle); GUILayout.Label( (l.PlayDetected ? "!" : ".") + (l.PlayDelayedDetected ? "!" : ".") + (l.RecDetected ? "!" : "."), lStyle); } } GUILayout.EndHorizontal(); } else { GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("Set Group (offs Debug Echo): ", lStyleSmall); for (byte i = 0; i < 5; i++) { if (GUILayout.Button((PhotonVoiceNetwork.Client.GlobalAudioGroup == i ? "[X] " : "[ ] ") + (i == 0 ? "No" : i.ToString()), bStyleSmall)) { PhotonVoiceNetwork.Client.GlobalAudioGroup = i; } } GUILayout.EndHorizontal(); var pvs = PhotonVoiceSettings.Instance; GUILayout.BeginHorizontal(); GUILayout.Label("Unity Mic: ", lStyleSmall); foreach (var x in Microphone.devices) { if (GUILayout.Button((pvs.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Unity && PhotonVoiceNetwork.MicrophoneDevice == x ? "[X] " : "[ ] ") + x, bStyleSmall)) { pvs.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Unity; PhotonVoiceNetwork.MicrophoneDevice = x; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Photon Mic: ", lStyleSmall); if (PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IsSupported) { for (int i = 0; i < PhotonVoiceNetwork.PhotonMicrophoneEnumerator.Count; i++) { if (GUILayout.Button((pvs.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Photon && PhotonVoiceNetwork.PhotonMicrophoneDeviceID == PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IDAtIndex(i) ? "[X] " : "[ ] ") + PhotonVoiceNetwork.PhotonMicrophoneEnumerator.NameAtIndex(i), bStyleSmall)) { pvs.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Photon; PhotonVoiceNetwork.PhotonMicrophoneDeviceID = PhotonVoiceNetwork.PhotonMicrophoneEnumerator.IDAtIndex(i); } } if (GUILayout.Button("Refresh", bStyleSmall)) { PhotonVoiceNetwork.PhotonMicrophoneEnumerator.Refresh(); } } else { // use 1st device in Unity device enumeration to display default device name (this may be wrong of course) if (Microphone.devices.Length > 0) { if (GUILayout.Button((pvs.MicrophoneType == PhotonVoiceSettings.MicAudioSourceType.Photon ? "[X] " : "[ ] ") + Microphone.devices[0], bStyleSmall)) { pvs.MicrophoneType = PhotonVoiceSettings.MicAudioSourceType.Photon; PhotonVoiceNetwork.PhotonMicrophoneDeviceID = -1; } } } GUILayout.EndHorizontal(); GUI.enabled = true; #if !UNITY_EDITOR && UNITY_PS4 UserProfiles.LocalUsers localUsers = new UserProfiles.LocalUsers(); UserProfiles.GetLocalUsers(localUsers); int userID = localUsers.LocalUsersIds[0].UserId.Id; pvs.PS4UserID = userID; #endif }
private void CharacterInstantiation_CharacterInstantiated(GameObject character) { rec = character.GetComponent <PhotonVoiceRecorder>(); }
private void OnLeftRoom() { rec = null; inGameSettings.SetActive(false); }