Photon Voice: How to correctly change scenes in Unity when connected to PhotonVoice?

edited March 2016 in Photon Voice
I have tried disconnecting then reconnecting in the next scene but it works inconsistently.

Hope there are other ways!

Answers

  • vadimvadim ✭✭✭
    What exactly you are doing and what does not work? Any errors or warning in log?
  • edited March 2016
    I have gone through many variations but right now what I have works, but feel incorrect.

    Using DontDestroyOnLoad() on the gameobject containing the PhotonVoice Network and Settings scripts, so they do not get destroyed between scenes and the destroyed bool does not get set.

    I am also disconnecting and connecting from the voice room before and after the scene has been loaded respectively. When I did not do the disconnect then connect I would get an error of null reference exception regarding the Voice.Client in PhotonVoiceNetwork script.

    It works well but I am pretty sure I am not supposed to have to do all that. Hope this information helps you help me.

    Thanks!

    EDIT: If it helps to know I am using PhotonNetwork Plugin v1.6.6 and and v1.0 for Voice. When I load scenes I use PhotonNetwork.LoadLevel.
  • Thanks for the input. We basically forgot about loading scenes and will fix Voice in that regard.
    Setting DontDestroyOnLoad() is fine. We do that in PUN, too, for a specific (hidden) GameObject.
    Of course, having to disconnect and reconnect is not how things should work.

    This will take a few days but gets high prio.
    We will post updates here, when we know more.
  • vadimvadim ✭✭✭
    I managed to reproduce similar failure but not sure that this is the same as yours since you did not provide any logs or other details.
    'NullReferenceException' happens when PhotonVoiceNetwork.singleton accessed after scene loaded if PhotonVoiceNetwork added to scene in editor. Try to remove it from scene and leave PhotonVoiceSettings only if default setting needs to be changed. Note that manually added PhotonVoiceSetting does not persist between scenes and you need to add it in every scene (or default values will be used)
  • So to make it persist between scene i need to have it in the scene I am switching to, not use "DontDestroyOnLoad" on the gameobject?
  • You should be able to apply "DontDestroyOnLoad" via code.
  • What is the proper way of switching scenes? I would prefer not to have to use DontDestroyOnLoad.
  • JohnTubeJohnTube mod
    edited July 2016
    @mcguinnessdr why can't you use DontDestroyOnLoad ?
  • @JohnTube I am developing for SteamVR, and there a few things that don't act very nicely with DontDestroyOnLoad, particularly having the VR Dashboard or keyboard open.
  • Hi @mcguinnessdr,

    I apologize about the delay.
    PUN and Voice for PUN rely on DontDestoryOnLoad for scene switching.
    I can't think of a workaround.
  • We apply DontDestroyOnLoad only to the GameObjects which get "our" components (e.g. PhotonVoiceNetwork).
    Can you try to explain how this is a problem? Maybe we can find a workaround.
Sign In or Register to comment.