Vote count:
0
I'm trying to create a simple registration interface for a mobile game I'm developing in Unity3D and I am using Parse to do so. It has been incredibly helpful but I am having a very hard time letting the user know where problems arise when they are registering. The documentation on this from Parse seems to have what I need but I can't get it to work without an error. Specifically my question is as follows:
1) How might I fix the following error?
error CS0308: The non-generic type 'Systems.Collections.IEnumerator' cannot be used with the type arguments.
From this line:
using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator()) {
Here is the code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Parse;
using System;
using System.IO;
using System.Threading.Tasks;
public class RegistrationButtonManager : MonoBehaviour {
Text displayError;
private string errorText = string.Empty;
private string username = string.Empty;
private string password = string.Empty;
private string email = string.Empty;
// Use this for initialization
void Start () {
displayError = GameObject.Find("txtLoginMessage").GetComponent<Text>();
}
// Update is called once per frame
void Update () {
displayError.text = errorText;
}
public void SendRegistration()
{
InputField[] registrationData = GameObject.Find("RegistrationPanel").GetComponentsInChildren<InputField>();
errorText = "Registering...";
username = registrationData[0].text;
password = registrationData[1].text;
email = registrationData[2].text;
var user = new ParseUser()
{
Username = username,
Password = password,
Email = email
};
try
{
user.SignUpAsync().ContinueWith(t => {
if (t.IsFaulted) {
// Errors from Parse Cloud and network interactions
using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator()) {
if (enumerator.MoveNext()) {
ParseException error = (ParseException) enumerator.Current;
// error.Message will contain an error message
// error.Code will return "OtherCause"
}
}
}
});
}
catch (InvalidOperationException e)
{
// Error from the SDK logic checks
// e.Message will contain the specific error
// ex: "Cannot sign up user with an empty name."
}
}
}
Any suggestions? Thanks!
asked 4 mins ago
How to pass errors with user registration to the user using Parse with Unity3D
Aucun commentaire:
Enregistrer un commentaire