Sign In Register

How can we help you today?

Start a new topic

Login Register for Unity?

Good evening!


I have been working on a game for a little over a month but have gotten stuck on connecting Gamesparks with my Unity game's login and register scene so I can't  give access to other players.


I have looked high and low for about a week and haven't found anything, I did follow THIS, a lot of videos and written tutorials but unfortunately fell to a dead end each time.


I did already ask this question in one of the learn area comments and looked around the Q and A area but saw nothing had been made and/or hadn't been answered in 4 months, I am very apologetic if this gets repeated.


If you have any easy to follow tutorials I would be over the moon to see them!


You're an absolute legend!

Thank you for taking time out of your day to help me! It's all working now and I am over the moon!


Thank you so much!


Until next time,

Ameesha

Hi Ameesha,


Could you try dragging the entire RegisterPlayer_Canvas from the Hierarchy into the OnClick() of your button as shown below? The function dropdown should then populate and allow you to choose the RegisterPlayerBttn function from the RegisterPlayer script.



Let me know if that works for you!


Regards,

Cillian.


2 people like this

Hello Cillian,

Thank you for the fast reply!


I seem to have everything as it is meant to be except I don't have the 

"RegisterPlayer.RegisterBttn" Function


image


This is my "Authenticate Player" script;

 

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class AuthenticatePlayer : MonoBehaviour
{


    public Text displayNameInput, userNameInput, passwordInput;

    public void AuthorizePlayerBttn()
    {
        Debug.Log("Authorizing Player...");
        new GameSparks.Api.Requests.AuthenticationRequest()
            .SetUserName("userNameInput.text")
            .SetPassword("passwordInput.text")
            .Send((response) =>
            {

                if (!response.HasErrors)
                {
                    Debug.Log("Player Authenticated... \n User Name: " + response.DisplayName);
                }
                else
                {
                    Debug.Log("Error Authenticating Player... \n " + response.Errors.JSON.ToString());
                }
            });
    }
}


 And my "Register Player" script;

 

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class RegisterPlayer : MonoBehaviour
{

    public Text displayNameInput, userNameInput, passwordInput;

    public void RegisterPlayerBttn()
    {
        Debug.Log("Regestering Player...");
        new GameSparks.Api.Requests.RegistrationRequest()
            .SetDisplayName (displayNameInput.text)
            .SetUserName (userNameInput.text)
            .SetPassword (passwordInput.text)
            .Send((response) =>
            {

                if (!response.HasErrors)
                {
                    Debug.Log("Player Register \n User Name " + response.DisplayName);
                }
                else
                {
                    Debug.Log("Error Regestering Player... \n " + response.Errors.JSON.ToString());
                }

            });
    }
}

 

And finally my Inputs;


image


Please let me know if there is anything else that you need, I'm wondering if maybe it's the names of my inputs?


Kind Regards,

Ameesha

Hi Ameesha,


Glad to hear you’re interested in using GameSparks. I’ve gone through the tutorials myself and was able to authenticate and register in Unity. Would you be able to ensure the following are correct in your Unity scene:

  •  You’ve set up the GameSparks SDK in your game. You should see a GameSparks option in your menu. If you click on that and choose Edit Settings, you’ll see your settings in the Inspector. Ensure your API Key and API Secret are correct. These are found in your Game Overview on the GameSparks portal. Could you also press the Test Configuration button and ensure you are getting GS AVAILABLE?

 

  •  You have a GameSparksManager object in your scene. This should include the GameSparkManager.cs script detailed in the guide and the GameSparksUnity.cs script found in Assets/GameSparks. GameSparksUnity also  requires you to drag in your GameSparksSettings which is found under Assets/GameSparks/Resources.

 

 

  • Attach the AuthenticatePlayer and RegisterPlayer scripts to the appropriate canvas. Ensure you have dragged in the correct Text Objects from the InputFields into the scripts eg. UserName_Input’s Text object should be dragged RegisterPlayer script’s User Name Input.

 

 

  • Your buttons are set up correctly as shown below.

 

Could you double check these and let me know if you are still having issues authenticating?


Regards,

Cillian.

Login to post a comment