"get_devices is not allowed to be called from a MonoBehaviour"
sosh
✭
Hi,
When I try to instantiate a prefab with PunVoiceRecorder (and it's two required components: PhotonVoiceSpeaker and AudioSource, plus a PhotonView), I get the error below:
The problem appears to be that PhotonVoiceNetworkSingleton/PhotonVoiceNetwork constructor calls Microphone.devices.Length (devices is a property), and that doesn't seem to be allowed by Unity.
Any ideas?
Thank you!
When I try to instantiate a prefab with PunVoiceRecorder (and it's two required components: PhotonVoiceSpeaker and AudioSource, plus a PhotonView), I get the error below:
get_devices is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'PhotonVoiceNetwork' on game object 'New Game Object'.
The problem appears to be that PhotonVoiceNetworkSingleton/PhotonVoiceNetwork constructor calls Microphone.devices.Length (devices is a property), and that doesn't seem to be allowed by Unity.
PhotonVoiceNetwork() { client = new UnityVoiceClient(this); client.loadBalancingPeer.DebugOut = DebugLevel.ALL; //PhotonNetwork.logLevel = PhotonLogLevel.Full; if (Microphone.devices.Length < 1) { Debug.LogError("PUNVoice: No microphone device found"); } // debug only // client.UseLossCompensation = false; // client.loadBalancingPeer.QuickResendAttempts = 3; // client.loadBalancingPeer.SentCountAllowance = 7; // PhotonNetwork.networkingPeer.QuickResendAttempts = 3; // PhotonNetwork.networkingPeer.SentCountAllowance = 7; //client.loadBalancingPeer.DebugOut = PhotonVoiceSettings.Instance.DebugLevel; // null ref while PhotonVoiceSettings is object's script }(Unity 5.4)
Any ideas?
Thank you!
0
Answers
-
Since the Microphone.devices.Length isn't doing much other than logging an error if 0, I removed this section of code.1
-
2 weeks and no one has answered this question. I also commented this out but would be nice to get some kind of an official response to this.0
-
Hi @Karel,
I apologize about the delay. Sometimes we miss some discussions on the forum. If we take more than 2 days to answer you can ping us via email.
Thank you for reporting this. The workaround suggested by @sosh does the job but rest assured a new version will be available soon with fixes and updates.
Thank you for choosing Photon!0