Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VoiceScript : MonoBehaviour
- {
- public PhotonView _photonView;
- public PhotonVoiceRecorder _rec;
- public AudioRecorder AudioRecorder;
- public static VoiceScript Instance;
- private void Awake()
- {
- if (Instance == null)
- {
- Instance = this;
- }
- else if (Instance != this)
- {
- Destroy(this);
- }
- AudioRecorder = GetComponent<AudioRecorder>();
- PhotonVoiceSettings.Instance.AutoTransmit = true;
- PhotonVoiceSettings.Instance.DebugInfo = true;
- this._photonView = GetComponentInParent<PhotonView>();
- if (this._photonView.isMine)
- {
- this._rec = GetComponentInParent<PhotonVoiceRecorder>();
- this._rec.Source = PhotonVoiceRecorder.AudioSource.Factory;
- PhotonVoiceNetwork.AudioSourceFactory = (rec) => AudioRecorder;
- this._rec.enabled = true;
- }
- else
- {
- Destroy(this);
- }
- }
- private void Start()
- {
- if (this._photonView.isMine)
- {
- this._rec.Transmit = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement