using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LoginSystem : MonoBehaviour {
public enum lMode{login,register};
public lMode LoginMode;
public GUISkin skin;
//login
private string user = "";
private string pass = "";
private int boolstatus;
//register
private string name = "";
private string password = "";
private string email = "";
private string Log;
public Texture LogTexture;
public string sceneMap;
[System.Serializable]
public class LoginParameters{
public Text LoginString;
public Text PassString;
public Toggle Remember;
}
[System.Serializable]
public class RegisterParameters{
public Text UserString;
public Text PassString;
public Text EmailString;
}
public LoginParameters LP;
public RegisterParameters RP;
public static int score;
public static string userName;
private string[] ListStrings;
public GameObject LoginM;
public GameObject RegisM;
public Text logText;
void Start () {
boolstatus = PlayerPrefs.GetInt("bs");
if (boolstatus == 1) {
LP.Remember.isOn = true;
}else{
LP.Remember.isOn = false;
}
if (LP.Remember.isOn == true) user = PlayerPrefs.GetString ("login");
}
void Update () {
logText.text = Log;
if (LoginMode == lMode.login) {
LoginM.SetActive(true);
RegisM.SetActive(false);
}else if(LoginMode == lMode.register){
LoginM.SetActive(false);
RegisM.SetActive(true);
}
if (LP.Remember.isOn == true) {
PlayerPrefs.SetString("login",user);
boolstatus = 1;
PlayerPrefs.SetInt("bs",boolstatus);
}else{
boolstatus = 0;
PlayerPrefs.SetInt("bs",boolstatus);
}
}
void OnGUI(){
GUI.skin = skin;
}
void RequestRegister(){
name = RP.UserString.text;
email = RP.EmailString.text;
password = RP.PassString.text;
if (name.Length < 1) {
Log = "Preencha o campo do Usuário.";
}else{
if(email.Length < 1){
Log = "Preencha o campo do E-Mail.";
}else{
if(password.Length < 1){
Log = "Preencha o campo da Senha.";
}else{
WWWForm register = new WWWForm();
register.AddField("user",name);
register.AddField("pass",password);
register.AddField("email",email);
WWW w = new WWW("http://nfx.comuv.com/register.php",register);
StartCoroutine(RequestRegisterInformations(w));
}
}
}
}
void RequestLogin(){
user = LP.LoginString.text;
pass = LP.PassString.text;
Log = "";
if (user.Length < 1) {
Log = "Preencha o campo do usuario";
}else{
if(pass.Length < 1){
Log = "Preencha o campo da senha";
}else{
WWWForm login = new WWWForm();
login.AddField("user",user);
login.AddField("pass",pass);
WWW w = new WWW("http://nfx.comuv.com/Login.php",login);
StartCoroutine(RequestLoginInformations(w));
}
}
}
IEnumerator RequestLoginInformations(WWW w){
yield return w;
if (w.error == null) {
Log = w.text;
ListStrings = w.text.Split(';');
if(ListStrings[0] == "Bem vindo"){
Log = "Seja " + ListStrings[0] + " " + ListStrings[1] +" ";
userName = ListStrings[1];
}
if(ListStrings[0] == "Bem vindo"){
Application.LoadLevel(sceneMap);
}
}
}
IEnumerator RequestRegisterInformations(WWW w){
yield return w;
if (w.error == null) {
Log = w.text;
if(Log == "Conta criada com sucesso!"){
LP.LoginString.text = RP.UserString.text;
LP.PassString.text = RP.PassString.text;
RP.UserString.text = "";
RP.EmailString.text = "";
RP.PassString.text = "";
LoginMode = lMode.login;
}
}
}
void RegisterMode(){
LoginMode = lMode.register;
}
void LoginMod(){
LoginMode = lMode.login;
}
}
How it doesn’t work… are there any error messages?
no error messages, just when i press the button, the button do not execute the function, im using Unity 5
this message is showing in xcode, but not as an error.
Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file.
→ applicationWillResignActive()
→ applicationDidBecomeActive()
i think is because of this issue
Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file.
→ applicationWillResignActive()
→ applicationDidBecomeActive()
how i can disable?
I’m not sure if it’s related to this:
https://www.reddit.com/r/apple/comments/397aor/apple_is_planning_on_forcing_https_for_all_apps/
You may need to use https which will required a valid SSL cert on your server (not self signed).
I recently purchased SSL certs from namecheap.com. They do a comodo PositiveSSL cert for about US$10 a year: https://www.namecheap.com/security/ssl-certificates/domain-validation.aspx
And for what you’re doing here, I’d suggest https as a minimum anyway.
For testing you can use a self signed cert but you’ll also need to do this: SSL with Self Signed Certificate on iOS - possible? - Unity Engine - Unity Discussions
if i buy this, them i need to put all my mysql and php inside, or not? what do i need to do after buy it?
$9.00/yr
PositiveSSL is one of the most popular and inexpensive SSL certificates in the industry. This hassle-free certificate is the ideal choice for websites where the brand’s trust is already established and organization verification is not needed. It’s ideal for securing low-volume e-commerce websites.
I have moved this thread to Platforms/iOS, as this thread is all about support and has nothing to do with teaching.
There are a few steps required - there are many guides on how to do this but the basic steps are:
- Create a CSR (Certificate Signing Request) (look for a guide that matches your hosting setup)
- Request the SSL certificate
- Get certificate from provider
- Install certificate on your webserver
Step 4 differs based on your hosting provider and webserver (apache, nginx, etc)