Question by
zak666 · Jan 15, 2016 at 10:37 AM ·
scripting problem
Register.cs(31,17): error CS0029: Cannot implicitly convert type `string' to `bool'
wellp :D dont get it...
using UnityEngine;
using System.Collections;
public class Register : MonoBehaviour {
// This script sends informatiopn to create a game file on the server, then promts the plsyer to
// procede to paying for their subscription to pay for their account for that month.
public string RegisterLink = "http://www.mysite/register.php";
public string Username = "";
public string password = "";
public string Email = "";
public GameObject Complete;
//-----------------------------------------------------------------------------------
public void register (){
StartCoroutine(RegisterNewPilot());
}
//-----------------------------------------------------------------------------------
private IEnumerator RegisterNewPilot(){
WWWForm form = new WWWForm();
form.AddField("Username", Username);
form.AddField("Email", Email);
form.AddField("Password", password);
WWW w = new WWW(RegisterLink, form);
yield return w;
if(w.error){Debug.Log("error please try again");
} else{
Complete.SetActive(true);
}
}
} // end class.
Comment
Answer by Munchy2007 · Jan 15, 2016 at 10:43 AM
You are making a Boolean comparison on a string at line 31
change your coroutine to this
private IEnumerator RegisterNewPilot(){
WWWForm form = new WWWForm();
form.AddField("Username", Username);
form.AddField("Email", Email);
form.AddField("Password", password);
WWW w = new WWW(RegisterLink, form);
yield return w;
if(!string.IsNullOrEmpty(w.error))
{
Debug.Log("error please try again");
}
else
{
Complete.SetActive(true);
}
}
Your answer