// Use this for initialization
    void Start()
    {
        mAuthCallback = (bool success) => {
            Debug.Log("In Auth callback, success = " + success);

            mSigningIn = false;
            if (success)
            {
                NavigationUtil.ShowMainMenu();
            }
            else
            {
                Debug.Log("Auth failed!!");
            }
        };

        // enable debug logs (note: we do this because this is a sample;
        // on your production app, you probably don't want this turned
        // on by default, as it will fill the user's logs with debug info).
        var config = new PlayGamesClientConfiguration.Builder()
                     .WithInvitationDelegate(InvitationManager.Instance.OnInvitationReceived)
                     .Build();

        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.DebugLogEnabled = true;

        // try silent authentication
        if (mAuthOnStart)
        {
            Authorize(true);
        }
    }
    // Handler script for the decline button.
    public void OnDecline()
    {
        if (processed)
        {
            return;
        }

        processed = true;
        InvitationManager.Instance.DeclineInvitation();

        NavigationUtil.ShowMainMenu();
    }
    // Update is called once per frame
    void Update()
    {
        inv = (inv != null) ? inv : InvitationManager.Instance.Invitation;
        if (inv == null && !processed)
        {
            Debug.Log("No Invite -- back to main");
            NavigationUtil.ShowMainMenu();
            return;
        }

        if (inviterName == null)
        {
            inviterName = (inv.Inviter == null || inv.Inviter.DisplayName == null) ? "Someone" :
                          inv.Inviter.DisplayName;
            message.text = inviterName + " is challenging you to a quiz race!";
        }

        if (RaceManager.Instance != null)
        {
            switch (RaceManager.Instance.State)
            {
            case RaceManager.RaceState.Aborted:
                Debug.Log("Aborted -- back to main");
                NavigationUtil.ShowMainMenu();
                break;

            case RaceManager.RaceState.Finished:
                Debug.Log("Finished-- back to main");
                NavigationUtil.ShowMainMenu();
                break;

            case RaceManager.RaceState.Playing:
                NavigationUtil.ShowPlayingPanel();
                break;

            case RaceManager.RaceState.SettingUp:
                message.text = "Setting up Race...";
                break;

            case RaceManager.RaceState.SetupFailed:
                Debug.Log("Failed -- back to main");
                NavigationUtil.ShowMainMenu();
                break;
            }
        }
    }
Exemplo n.º 4
0
 //Handles resetting the gamepad state then navigating to the main menu.
 void ShowMainMenu()
 {
     EnableGamepad(false);
     NavigationUtil.ShowMainMenu();
 }