0
\$\begingroup\$

OnRoomConnected always return false, Im stuck...(Authenticate is success). Thank you for attention.

private List<Participant> participants;

public void Authenticate()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .Build();

    PlayGamesPlatform.InitializeInstance(config);
    // recommended for debugging:
    // PlayGamesPlatform.DebugLogEnabled = true;
    // Activate the Google Play Games platform
    PlayGamesPlatform.Activate();

    Social.localUser.Authenticate((bool success) =>
    {
        if (success)
        {
            Debug.Log("Authentication succeeded");
            //CreateQuickGame();
        }
        else
        {
            Debug.Log("Authentication failed");
        }
    });
}

public void CreateQuickGame()
{
    const int MinOpponents = 2, MaxOpponents = 2;
    const int GameVariant = 0;
    PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen(MinOpponents, MaxOpponents, GameVariant, this);
}

#region RealTimeMultiplayerListener implementation

public void OnLeftRoom()
{
    SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
}

public void OnParticipantLeft(Participant participant)
{
    SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
}

public void OnPeersConnected(string[] participantIds)
{
    Debug.Log("OnPeersConnected");
    byte[] message = Encoding.ASCII.GetBytes("Test"); // build your message
    bool reliable = true;
    PlayGamesPlatform.Instance.RealTime.SendMessageToAll(reliable, message);
}

public void OnPeersDisconnected(string[] participantIds)
{
    //SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);
}

public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data)
{
}

public void OnRoomConnected(bool success)
{
    if (success)
    {
        Debug.Log("Room Connected success");

        MainScene ms = new MainScene();
        ms.Waithing_sprite.SetActive(true);
        // Successfully connected to room!
        // ...start playing game...
        //PlayersNames[0] = participants[0].DisplayName;
        //PlayersNames[1] = participants[1].DisplayName;
        //PlayersNames[2] = participants[2].DisplayName;
        //GenerateBoard();
        //bool reliability = true;
        //string data = "Instantiate:0:1:2";
        //byte[] bytedata = System.Text.ASCIIEncoding.Default.GetBytes(data);
        //PlayGamesPlatform.Instance.RealTime.SendMessageToAll(reliability, bytedata);
    }
    else
    {
        Debug.Log("Room Connected FAIL");
        PlayGamesPlatform.Instance.RealTime.LeaveRoom();
        //Loading.text = "Error!";
        //Back.SetActive(true);
        // Error!
        // ...show error message to user...
    }
}

public void OnInvitation(Invitation invitation, bool shouldAutoAccept)
{
    // handle the invitation
    if (shouldAutoAccept)
    {
        PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitation.InvitationId, this);
    }
    else
    {
        // do some other stuff.
    }
}

public void OnRoomSetupProgress(float progress)
{
    Debug.Log("Room Progress Waithing players");
    List<Participant> participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();
    // show the default waiting room.
    if (participants.Count != 3)
    {
        PlayGamesPlatform.Instance.RealTime.ShowWaitingRoomUI();
        Debug.Log("Room Progress Waithing players");
    }
    else
    {
        Debug.Log("Room Progress 100");

        MainScene ms = new MainScene();
        ms.MoveToGame();
        PlayersNames[0] = participants[0].DisplayName;
        PlayersNames[1] = participants[1].DisplayName;
        PlayersNames[2] = participants[2].DisplayName;
    }
}
\$\endgroup\$

1 Answer 1

-1
\$\begingroup\$

Okay, just need upload apk on the google play console

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .