// Pass in a placeholder player name so that the dialog can display who has startedthe authorisation
    public void Show(Fragment.AuthRequestCode code, string playerName, string status)
    {
        if (code.QRBitmapPixels == null)
        {
            Debug.Log("Fragment Error: AuthRequestCode with no pixel data passed into FragmentAuthenticationUI.Show(). Most likely Fragment has been initialised incorrectly - do you have a valid node connection and appID?");
            return;
        }

        _hide = false;

        // Set a placeholder name
        PlayerName.text       = playerName;
        PlayerTextStatus.text = status;

        // Build a texture from the pixels in the AuthRequestCode
        Texture2D QRTexture = new Texture2D(code.QRBitmapWidth, code.QRBitmapWidth, TextureFormat.ARGB32, false);

        QRTexture.LoadRawTextureData(code.QRBitmapPixels);
        QRTexture.filterMode = FilterMode.Point;
        QRTexture.Apply();
        // Apply the texture as a sprite in the UI image
        QRCodeSecret.sprite = Sprite.Create(QRTexture, new Rect(0, 0, QRTexture.width, QRTexture.height), new Vector2(0, 0));
        // Text version of the QR code
        TextSecret.text = code.text;
        // Display this UI widget
        gameObject.SetActive(true);
    }
Example #2
0
    void Start()
    {
        Fragment.Result result = Fragment.Initialise(GameID, LocalServerURL);
        if (result != Fragment.Result.SR_OK)
        {
            string detailedErrorDesc = "";
            Fragment.GetLastError(ref detailedErrorDesc);
            Debug.Log("Fragment error desc: " + detailedErrorDesc);
        }

        Fragment.AuthRequestCode code = new Fragment.AuthRequestCode();
        result = Fragment.PlayerAuthRequest(0, ref code);
        if (result != Fragment.Result.SR_OK)
        {
            string detailedErrorDesc = "";
            Fragment.GetLastError(ref detailedErrorDesc);
            Debug.Log("Fragment error desc: " + detailedErrorDesc);
        }

        AuthUI.Show(code, "Player 1", "Join the game");
    }
Example #3
0
    //

    public void PlayerConnect(int playerIndex)
    {
        // temp
        //_players[playerIndex].CurrentState = Player.State.AuthorisedPlaying;
        //_players[playerIndex].AvailableCars = _carLibrary.GetAvailableCarsAI();
        //return;
        // end temp

        if (_players[playerIndex].CurrentState == Player.State.NotPlaying)
        {
            Fragment.AuthRequestCode code = new Fragment.AuthRequestCode();
            Fragment.PlayerAuthRequest((uint)playerIndex, ref code);

            _authUI.Show(code, GetPlayerName(playerIndex), "Join the game");

            _players[playerIndex].CurrentState = Player.State.AuthoriseInProgress;
        }
        else
        {
            // ERROR
        }
    }