Wednesday 28 June 2017

Registration Form Unity

hello guys, here is the simple nice script for registration form with API

Register.cs

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

public class Register : MonoBehaviour {

public InputField Username;
public InputField Email;
public InputField Password;

  //Change link with your RegistrationAPI.
private string RegisterAPI="http://YourAPILink";

  public void RegisterClick()
{
WWWForm form = new WWWForm ();
        //Change username/email/password with your tabel parameter

form.AddField ("username",Username.text);
form.AddField ("password",Password.text);
form.AddField ("email",Email.text);

       WWW w = new WWW (RegisterAPI,form);
StartCoroutine(RegistrationFunc(w));
}

   //Get Responce, e.g. Registration successfully

IEnumerator RegistrationFunc(WWW w)
{
yield return w;
if (w.error == null)
{
Debug.Log (w.text);
}
else
{
Debug.Log ("ERROR: " + w.error + "\n");
}
}

}

No comments:

Post a Comment