Best way to see if MatchMaker is initialized?

If you attempt to start the match maker and create a game in the same frame you get a null reference exception in the match maker itself. It appears that 'client' is initialized in Start() which isn't called until a frame later (due to it being added via AddComponent I'm assuming). Waiting a frame throws an exception that the client isn't ready. If I try to access the public client member by casting the matchMaker member in NetworkManager I get an error saying IPhotonPeerListener is in an unreferenced assembly.

Comments

  • Hello Kelso,

    You can call the "ready" property from the Photon Client, it will only return true when the client is connected to Photon Cloud and ready to create/list/join matches. Take a look on the snippet below.
    // ----- CLASS DEFINITION -----
        
    private void Update()
    {
        PhotonMatchmaker matchMaker = GetComponent<PhotonMatchmaker>();
        if (matchMaker != null && matchMaker.client.ready)
        {
            // ready!
        }
    }
  • Thanks ramon,

    Looks like you guys have the Editor checked as an excluded platform for Photon3Unity3d.dll so none of the references could resolve correctly.

    Might want to update that in the next release :smiley:
  • Thanks for the note!