Autologin

When a user is logged in to Y8 Account and opens a game that uses the Y8 Account SDK, they will logged in automatically. To do this, call Autologin once in the first scene’s Start() method. The autologin call should happen just after initializing the SDK. Note that the autologin feature only works in a browser and not in the Unity editor.

Autologin Example

Idnet.I.AutoLogin((user, autoLoginException) => {
 if (autoLoginException != null)
 {
#if UNITY_EDITOR
    Debug.Log("Autologin does not work in the Unity Editor,try it browser!");
#else
  // Callback: Autologin failed
    Debug.Log("Autologin failed,probably user not logged-in to https://account.y8.com");
#endif
 }
 else
 {
    if (Idnet.User.LoggedIn())
    {
       // Callback: Autologin successfull
       Debug.Log("Auto login success. " + "Nickname " + Idnet.User.Current.Nickname);
    }
 }
});

Login Menu Example

Idnet.I.Login(loginRegisterException => {
 if (Idnet.User.LoggedIn())
 {
    // Callback: Login succesfull.
    Debug.Log("User logged in: " + "Nickname " + Idnet.User.Current.Nickname);
 }
});

Getting User Data

if(Idnet.User.LoggedIn())
{
   Debug.Log("Welcome: " + Idnet.User.Current.Nickname);
}
else
{
   Debug.Log("Not logged-in to IDnet" );
}

Register Menu Example

Idnet.I.Register(loginRegisterException => {
 if (Idnet.User.LoggedIn())
 {
    // Callback: Login succesfull.
    Debug.Log("User logged in: " + "Nickname " + Idnet.User.Current.Nickname);
 }
});

Logout

Logout buttons are not needed as users can logout from Y8 Account. If you need to logout for testing, use the following example.

	Idnet.I.Logout ();