Advertisement
Guest User

VoiceScript

a guest
Jun 4th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public class VoiceScript : MonoBehaviour
  2. {
  3. public PhotonView _photonView;
  4. public PhotonVoiceRecorder _rec;
  5.  
  6.  
  7. public AudioRecorder AudioRecorder;
  8.  
  9. public static VoiceScript Instance;
  10.  
  11. private void Awake()
  12. {
  13. if (Instance == null)
  14. {
  15. Instance = this;
  16. }
  17. else if (Instance != this)
  18. {
  19. Destroy(this);
  20. }
  21.  
  22.  
  23. AudioRecorder = GetComponent<AudioRecorder>();
  24.  
  25. PhotonVoiceSettings.Instance.AutoTransmit = true;
  26.  
  27.  
  28. PhotonVoiceSettings.Instance.DebugInfo = true;
  29. this._photonView = GetComponentInParent<PhotonView>();
  30.  
  31. if (this._photonView.isMine)
  32. {
  33. this._rec = GetComponentInParent<PhotonVoiceRecorder>();
  34. this._rec.Source = PhotonVoiceRecorder.AudioSource.Factory;
  35. PhotonVoiceNetwork.AudioSourceFactory = (rec) => AudioRecorder;
  36. this._rec.enabled = true;
  37. }
  38. else
  39. {
  40. Destroy(this);
  41. }
  42. }
  43.  
  44. private void Start()
  45. {
  46. if (this._photonView.isMine)
  47. {
  48. this._rec.Transmit = true;
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement