我正在尝试在 Unity 中创建帐户创建系统,但遇到以下错误:
错误 CS0246:找不到类型或命名空间名称响应。您是否缺少程序集参考?
脚本网络连接:
public void CreateUser(string userName , string email , string pass , Action<Response> response){
StartCoroutine (Make_CreateUser (userName, email, pass, response));
}
private IEnumerator Make_CreateUser(string userName , string email , string pass , Action<Response> response){
WWWForm form = new WWWForm ();
form.AddField ("userName", userName);
form.AddField ("email", email);
form.AddField ("pass", pass);
WWW w = new WWW ("http://localhost/game/createUser.php", form);
yield return w;
response (JsonUtility.FromJson<Response> (w.text));
}
[Serializable]
public class Response {
public bool done = false;
public string message = "";
}
菜单控制器脚本:
[SerializeField] private InputField userNameInput = null;
[SerializeField] private InputField emailInput = null;
[SerializeField] private InputField passwordInput = null;
[SerializeField] private InputField RepasswordInput = null;
[SerializeField] private Text textInput = null;
private NetworkConnection s_NetworkConnection = null;
public GameObject Register;
private void Awake(){
s_NetworkConnection = GameObject.FindObjectOfType<NetworkConnection> ();
}
public void SubmitRegister(){
if (userNameInput.text == "" || emailInput.text == "" || passwordInput.text == "" || RepasswordInput.text == "") {
textInput.text = "Please, complete all fields";
return;
}
if (passwordInput.text == RepasswordInput.text) {
textInput.text = "Loading...";
s_NetworkConnection.CreateUser (userNameInput.text, emailInput.text, passwordInput.text, delegate (Response response) {
textInput.text = response.message;
});
} else {
textInput.text = "Passwords are not equals";
}
}
public void OnMouseDown ()
{
Register.SetActive (!Register.activeSelf);
}
DIEA
相关分类