ctalyst® – Using your own Login Menu

This article will discuss how to implement ctalyst® login system with Login Menu of your own. This article assume that ctalyst® Unity SDK is already installed in you project.

Prerequisites:

Download the ctalyst® Unity Plugin and set it up in your project. For more details on setting up ctalsyt® SDK read Unity 3D – Getting Started with ctalyst.

Login a User to ctalyst®:

Initializing Plugin:

Create Empty GameObject and name it ctalystLoginHandler. Drag and drop the ctalyst_Game_Registration Component from ctalyst.dll  file under Assets/DLI/plugins folder onto onto ctalystLoginHandler GameObject.  Fill up the your Publisher Token in “Token” field and Game ID in “Content ID” field in Inspector Window of ctalystLoginHandler.

Following code will initialize the Registration-Login Component of ctalyst® Unity Plugin. It can be added to script that can be attached to any GameObject in the Login Menu scene. It will also add method RunOnLoginSuccessful to be executed when login is successful and method RunOnLoginNotSuccessful when login is unsuccessful. You can define your own code in these methods to implement.


  private ctalyst.ctalyst_Game_Registration ctalystRegisterLogin;
  void Awake()
  {
      ctalystRegisterLogin = gameObject.GetComponent();
      
      // Add custom method to execute when Login is Successful
      ctalyst.ctalyst_Game_Registration.AddUserLoginSuccessfulEventListener(RunOnLoginSuccessful);

      // Add custom method to execute when Login is NOT Successful
      ctalyst.ctalyst_Game_Registration.AddErrorEventListener(RunOnLoginNotSuccessful);
  }
  public void RunOnLoginSuccessful()
  {
      // This method will execute if login is successful
      // You can put custom code here ...
  }

  public void RunOnLoginNotSuccessful()
  {
      // This method will execute if login is not successful
      // You can put custom code here ...
  }

Now the plugin is configured to be used to login user to ctalyst®. Following method should be used to make API call to login the user to ctalyst®.


   ctalystRegisterLogin.UserLogin(user_email, user_password);

Before using this code snippet, please  make sure that user is already Registered to ctalyst® and had confirmed his/her email.