0
votes

I am creating an android multiplayer game with Unity, which uses google play services. When i try to create a room:

public void SingInAndStartMPGame(){

    if (!PlayGamesPlatform.Instance.localUser.authenticated) {
        PlayGamesPlatform.Instance.localUser.Authenticate ((bool success) => {
            if (success) {
                Debug.Log ("We are singed in, Welcome " + PlayGamesPlatform.Instance.localUser.userName);
                StartMatchMaking();
            } else {
                Debug.Log ("We are not singed in");
            }
        });
    } else {
        Debug.Log ("You are already singed in");
        StartMatchMaking ();
    }

}
private void StartMatchMaking() {

    PlayGamesPlatform.Instance.RealTime.CreateQuickGame (minimumOpponents, maximumOpponents, gameVariation, this);

}

And I get this messages in Logcat:

08-18 23:31:18.712: I/Unity(12810): You are already singed in 08-18 23:31:18.712: I/Unity(12810):
08-18 23:31:18.712: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.712: I/Unity(12810): True 08-18 23:31:18.712: I/Unity(12810):
08-18 23:31:18.712: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: Activating PlayGamesPlatform. 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: PlayGamesPlatform activated: GooglePlayGames.PlayGamesPlatform 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: Activating PlayGamesPlatform. 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: PlayGamesPlatform activated: GooglePlayGames.PlayGamesPlatform 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: QuickGame: Setting MinPlayersToStart = 2 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: OnData Callback has addr: 35 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: BeforeRoomCreateStartedState.IsNonPreemptable: Is preemptable by default. 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: Entering state: RoomCreationPendingState 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:18.723: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:18 +03:00 DEBUG: RoomCreationPendingState.OnStateEntered: Defaulting to no-op. 08-18 23:31:18.723: I/Unity(12810):
08-18 23:31:18.723: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.812: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:20 +03:00 DEBUG: Entering internal callback for RealtimeManager#InternalRealTimeRoomCallback 08-18 23:31:20.812: I/Unity(12810):
08-18 23:31:20.812: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.812: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:20 +03:00 DEBUG: Entering state: ShutdownState 08-18 23:31:20.812: I/Unity(12810):
08-18 23:31:20.812: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.812: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:20 +03:00 DEBUG: ShutdownState.OnStateEntered: Defaulting to no-op. 08-18 23:31:20.812: I/Unity(12810):
08-18 23:31:20.812: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.812: I/Unity(12810):
08-18 23:31:20.812: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.812: I/Unity(12810): Uh-oh. Encountered some error connecting to the room! 08-18 23:31:20.812: I/Unity(12810):
08-18 23:31:20.812: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51) 08-18 23:31:20.829: I/Unity(12810): [Play Games Plugin DLL] 08/18/18 23:31:20 +03:00 DEBUG: ShutdownState.IsRoomConnected: Returning room not connected. 08-18 23:31:20.829: I/Unity(12810):
08-18 23:31:20.829: I/Unity(12810): (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

Any help would be appreciated.

1

1 Answers

0
votes

Use Social instead PlayGamesPlatform.Instance

Try this code:

using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.Multiplayer;
using UnityEngine.SocialPlatforms;

...

void Start()
{
    PlayGamesClientConfiguration Config = new PlayGamesClientConfiguration.Builder().Build();

    PlayGamesPlatform.InitializeInstance(Config);
    PlayGamesPlatform.Activate();
}

public void SingInAndStartMPGame()
{
    Social.localUser.Authenticate((bool Success) =>
    {
        if (Success)
        {
            Debug.Log ("We are singed in, Welcome!");
            StartMatchMaking();
        }
        else
        {
            Debug.Log ("We are not singed in");
        }
    });
}


public void StartMatchMaking()
{
    PlayGamesPlatform.Instance.RealTime.CreateQuickGame(minimumOpponents, maximumOpponents, gameVariation, this);
}

public void OnRoomConnected(bool success)
{
    // Do something after connect
}

public void OnLeftRoom()
{
    throw new System.NotImplementedException();
}

public void OnParticipantLeft(Participant participant)
{
    throw new System.NotImplementedException();
}

public void OnPeersConnected(string[] participantIds)
{
    throw new System.NotImplementedException();
}

public void OnPeersDisconnected(string[] participantIds)
{
    throw new System.NotImplementedException();
}

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

Hope this is what you want.