示例#1
0
    private IEnumerator PhotonVoiceInstantiationForLocalObserver()
    {
        Debug.Log("[PUN] setup voice for observer by adding Speaker,Recorder,VoiceView ");

        //add audio source
        AudioSource audioSource = localObserver.GetComponent <AudioSource>();

        ////add speaker to the element which holds the audio source
        Speaker speaker = audioSource.gameObject.AddComponent <Speaker>();

        ////add recorder to the element that has the photonView
        Recorder recorder = localObserver.gameObject.AddComponent <Recorder>();

        recorder.DebugEchoMode = false;

        ////add Photonvoice view to the local avatar
        PhotonVoiceView voiceView = localObserver.gameObject.AddComponent <PhotonVoiceView>();

        voiceView.RecorderInUse     = recorder;
        voiceView.SpeakerInUse      = speaker;
        voiceView.SetupDebugSpeaker = true;

        ////start transmission
        yield return(voiceView.RecorderInUse.TransmitEnabled = true);

        voiceView.RecorderInUse.StartRecording();
    }
示例#2
0
 public void CreateVoiceView()
 {
     DestroyVoiceObject();
     voiceObject = PhotonNetwork.Instantiate("Photon/VoicePrefab", Vector3.one, Quaternion.identity);
     voiceView   = voiceObject.GetComponent <PhotonVoiceView>();
     recorder    = PhotonVoiceNetwork.Instance.PrimaryRecorder;
 }
    protected override void Awake()
    {
        this.photonVoiceView = this.GetComponentInParent <PhotonVoiceView>();
        this.photonView      = this.GetComponentInParent <PhotonView>();
        Collider collider = this.GetComponent <Collider>();

        collider.isTrigger = true;
    }
示例#4
0
 private void Awake()
 {
     //Set the recorder
     _photonVoiceView = GetComponent <PhotonVoiceView>();
     _photonVoiceView.UsePrimaryRecorder = true;
     PhotonVoiceNetwork.Instance.AutoLeaveAndDisconnect = true;
     StartCoroutine(SetUpRecorder());
 }
示例#5
0
 private void Awake()
 {
     this.canvas = this.GetComponent <Canvas>();
     if (this.canvas != null && this.canvas.worldCamera == null)
     {
         this.canvas.worldCamera = Camera.main;
     }
     this.photonVoiceView = this.GetComponentInParent <PhotonVoiceView>();
 }
    protected override void Awake()
    {
        this.photonVoiceView = this.GetComponentInParent <PhotonVoiceView>();
        this.photonView      = this.GetComponentInParent <PhotonView>();
        Collider tmpCollider = this.GetComponent <Collider>();

        tmpCollider.isTrigger = true;
        this.IsLocalCheck();
    }
示例#7
0
 private void Awake()
 {
     canvas = GetComponent <Canvas>();
     if (canvas != null && canvas.worldCamera == null)
     {
         canvas.worldCamera = Camera.main;
     }
     photonVoiceView = GetComponentInParent <PhotonVoiceView>();
 }
示例#8
0
    public override void OnJoinedRoom()
    {
        Debug.Log("OnjoinedRoom");
        var go = PhotonNetwork.Instantiate("Photon/VoicePrefab", Vector3.one, Quaternion.identity);

        voiceView = go.GetComponent <PhotonVoiceView>();
        recorder  = PhotonVoiceNetwork.Instance.PrimaryRecorder;

        Debug.Log("recorder " + recorder);
        OnJoinRoom.OnNext(true);
    }
        private void CharacterInstantiation_CharacterInstantiated(GameObject character)
        {
            if (this.recorder) // probably using a global recorder
            {
                return;
            }
            PhotonVoiceView photonVoiceView = character.GetComponent <PhotonVoiceView>();

            if (photonVoiceView.IsRecorder)
            {
                this.recorder = photonVoiceView.RecorderInUse;
            }
        }
示例#10
0
    private IEnumerator PhotonVoiceInstantiationForLocalAvatar()
    {
        Debug.Log("[PUN] OVRAvatar completed instantiation of LocalAvatar now we setup voice by adding Speaker,Recorder,VoiceView ");

        //get audiosource from the localavatar
        while (localAvatar.GetComponentInChildren <AudioSource>() == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        AudioSource audioSource = localAvatar.GetComponentInChildren <AudioSource>();

        //////get the ovr
        while (audioSource.gameObject.GetComponent <OVRLipSyncContext>() == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        OVRLipSyncContext LipSyncContext = audioSource.gameObject.GetComponent <OVRLipSyncContext>();

        LipSyncContext.audioSource = audioSource;
        if (voiceDebug)
        {
            LipSyncContext.audioLoopback = true;             // Don't use mic.
        }
        else
        {
            LipSyncContext.audioLoopback = false;
        }
        LipSyncContext.skipAudioSource = false;

        ////add speaker to the element which holds the audio source
        Speaker speaker = audioSource.gameObject.AddComponent <Speaker>();

        ////add recorder to the element that has the photonView
        Recorder recorder = photonView.gameObject.AddComponent <Recorder>();

        recorder.DebugEchoMode = true;

        ////add Photonvoice view to the local avatar
        PhotonVoiceView voiceView = photonView.gameObject.AddComponent <PhotonVoiceView>();

        voiceView.RecorderInUse     = recorder;
        voiceView.SpeakerInUse      = speaker;
        voiceView.SetupDebugSpeaker = true;

        ////start transmission
        yield return(voiceView.RecorderInUse.TransmitEnabled = true);

        voiceView.RecorderInUse.StartRecording();
    }
示例#11
0
    protected override void Awake()
    {
        base.Awake();
#if !UNITY_WEBGL && PVOICE
        if (!isBot)
        {
            PRecorder = GetComponent <PhotonVoiceView>();
        }
#endif
        if (!isBot)
        {
            DamagerManager = GetComponent <bl_PlayerDamageManager>();
        }
        else
        {
            AIHealth = GetComponent <bl_AIShooterHealth>();
        }
        ShowHealthBar = bl_GameData.Instance.ShowTeamMateHealthBar;
    }
示例#12
0
 /// <summary>
 /// Enables/Disables recording based on the settings in this component.
 /// </summary>
 public virtual void Start()
 {
     if (!NetworkManager.networkManager)
     {
         Debug.LogError("VoiceChat - Disabling myself because I was unable to locate the Network Manager. Is it in the scene?");
         enabled = false;
         return;
     }
     if (isPlayer == true)
     {
         if (!GetComponent <PhotonVoiceView>() && isPlayer == true)
         {
             Debug.LogError("This component is marked as a player but doesn't have a PhotonVoiceView component attached!");
         }
         view = GetComponent <PhotonVoiceView>();
         view.RecorderInUse      = (view.RecorderInUse == null) ? NetworkManager.networkManager.voiceRecorder : view.RecorderInUse;
         view.UsePrimaryRecorder = true;
         view.SetupDebugSpeaker  = debugging;
         view.SpeakerInUse       = (view.SpeakerInUse == null) ? GetComponent <Speaker>() : view.SpeakerInUse;
         speaker = GetComponent <Speaker>();
     }
     else
     {
         if (!GetComponent <Recorder>() && isPlayer == false)
         {
             Debug.LogError("This component is marked as not a player but doesn't have a Recorder component attached!");
         }
         if (!GetComponent <PhotonVoiceNetwork>() && isPlayer == false)
         {
             Debug.LogError("This component is marked as not a player but doesn't have a PhotonVoiceNetwork component attached!");
         }
         originalAudioVolume      = AudioListener.volume;
         recorder                 = GetComponent <Recorder>();
         recorder.TransmitEnabled = !pushToTalk;
         recorder.IsRecording     = !pushToTalk;
         GetComponent <Recorder>().DebugEchoMode          = debugging;
         PhotonVoiceNetwork.Instance.Client.StateChanged += VoiceClientStateChanged;
     }
     OnStart.Invoke();
 }
示例#13
0
 private void Start()
 {
     view = GetComponent <PhotonVoiceView>();
 }
示例#14
0
 public void SetUpPhotonVoiceView(PhotonVoiceView voiceView)
 {
     playerVoiceView = voiceView;
     recorder        = PhotonVoiceNetwork.Instance.PrimaryRecorder;
     OnPhotonVoiceCreated.OnNext(Unit.Default);
 }
 private void Awake()
 {
     this.photonVoiceView = this.GetComponent <PhotonVoiceView>();
 }
 private void Awake()
 {
     this.photonVoiceView = this.GetComponent <PhotonVoiceView>();
     this.SetActiveSafe(this.pointerUp, false);
     this.SetActiveSafe(this.pointerDown, false);
 }
 private void Start()
 {
     this.photonVoiceView = this.GetComponent <PhotonVoiceView>();
 }
示例#18
0
 private void Awake()
 {
     _animator        = GetComponentInParent <Animator>();
     _canvas          = GetComponent <Canvas>();
     _photonVoiceView = GetComponentInParent <PhotonVoiceView>();
 }
    void Start()
    {
        GameObject player = PhotonNetwork.Instantiate(_player.name, Vector3.zero, Quaternion.identity);

        voiceView = player.GetComponent <PhotonVoiceView>();
    }