Email & Password Login

The ReneAPIManager.Login method provides an easy way to authenticate users on the Rene verse Portal through your game, bringing many benefits of it. Below, you'll find comprehensive documentation that explains its usage and integration into your Unity project.

Class Overview

Namespace: ReneVerse

Class: ReneAPIManager

The ReneAPIManager class is a utility class that manages connections and interactions with the ReneVerse API. It provides several static methods to initialize the API, handle user authentication, and perform various other operations.

Method: Login

Signature:

public static async Task<bool> Login(string email, string password)

Description: The Login method authenticates a user with the ReneVerse API using the provided email and password. If the login is successful, it retrieves and stores the user's profile data.

Parameters:

  • email (string): The email address of the user.

  • password (string): The password of the user.

Returns:

  • Task<bool>: A task representing the asynchronous operation. The task result is a boolean indicating whether the login was successful.

Usage: The Login method can be called from any script within the Unity project. Typically, it would be called when the user attempts to log in through the game's user interface.

Example Usage in Unity

Here's an example of how to use the Login method within a Unity script. This example assumes you have a basic UI setup with input fields for the email and password, and a button to trigger the login process.

  1. Create a Login UI:

    • Add Input Fields for email and password.

    • Add a Button for the login action.

  2. Attach a Script to the Button:

    csharpCopy codeusing UnityEngine;
    using UnityEngine.UI;
    using ReneVerse;
    
    public class LoginManager : MonoBehaviour
    {
        public InputField emailInputField;
        public InputField passwordInputField;
        public Text statusText;
    
        public async void OnLoginButtonClicked()
        {
            string email = emailInputField.text;
            string password = passwordInputField.text;
    
            bool loginSuccessful = await ReneAPIManager.Login(email, password);
    
            if (loginSuccessful)
            {
                statusText.text = "Login successful!";
                // Proceed to the next scene or game state.
                // Now players have the benefits of logging in
            }
            else
            {
                statusText.text = "Login failed. Please check your credentials.";
            }
        }
    }
  3. Initialize the ReneVerse API: Ensure that the API is initialized before calling the Login method. This can be done in the Start method of a Unity script or any other appropriate place in your game.

    csharpCopy codevoid Start()
    {
        ReneAPIManager.InitializeAPI();
    }

Detailed Explanation

Initialization

Before calling the Login method, it is crucial to initialize the ReneVerse API. The InitializeAPI method sets up the API using the credentials stored in the ReneAPICreds in the Reneverse Window that Rene Sdk Provides (Shift + R/ Window -> Reneverse Settings).

Handling Login

The Login method in ReneAPIManager utilizes the UserAPI class to send a login request to the ReneVerse backend. Upon successful authentication, the method fetches the user's profile.

Customization

Developers can customize the login implementation as needed. For instance, input parameters can be gathered through different UI elements, such as text fields or dropdowns. The process of integrating the login functionality into the game's flow is flexible and can be adapted to fit various design requirements.

Summary

The ReneAPIManager.Login method provides a straightforward way to handle user authentication to Reneverse in Unity games using the ReneVerse API. By following the steps outlined above, developers can easily integrate login functionality into their games, allowing users to authenticate with their ReneVerse credentials. The method is asynchronous and returns a boolean indicating the success of the login attempt, enabling developers to handle login success and failure appropriately within their game.

Last updated