Пример #1
0
    private IEnumerator Signup()
    {
        WWWForm form = new WWWForm();

        form.AddField("Username", rv.suUsernameIn.text);
        form.AddField("Email", rv.suEmailIn.text);
        form.AddField("Password", rv.suPassIn.text);

        WWW www = new WWW(rv.reqURL + "/api/Users/Create", form.data);

        yield return(www);

        if (www.error != null)
        {
            Debug.Log(www.error);

            if (www.text.Contains("Username already exists"))
            {
                rv.ShowInfo("Username already exists");
            }
            else
            {
                rv.ShowInfo("Connection error");
            }
        }
        else
        {
            string jsonData = www.text;

            User user = JsonUtility.FromJson <User>(jsonData);
            UserManager.userID   = int.Parse(user.userID);
            UserManager.username = user.username;
            UserManager.token    = user.token;
            SaveManager.SaveEmail(user.email);
            rv.suUsernameIn.text = "";
            rv.suEmailIn.text    = "";
            rv.suPassIn.text     = "";
            rv.suConfPassIn.text = "";
            rv.siEmailIn.text    = LoadManager.LoadEmail();

            rv.qaPanel.SetActive(true);
            rv.signupPanel.SetActive(false);
        }
    }
Пример #2
0
    private void Awake()
    {
        rv = transform.GetChild(0).GetComponent <RefVars>();

        // Signup
        rv.suUsernameIn.onEndEdit.AddListener(delegate { ValUsername(); });
        rv.suEmailIn.onEndEdit.AddListener(delegate { ValEmail(); });
        rv.suPassIn.onEndEdit.AddListener(delegate { ValPass(); });
        rv.suConfPassIn.onEndEdit.AddListener(delegate { ValPassConf(); });
        rv.suSignupB.onClick.AddListener(delegate { OnCreateAccountClick(); });
        rv.suSigninB.onClick.AddListener(delegate { OpenSignin(); });

        // Signin
        rv.siSigninB.onClick.AddListener(delegate { StartCoroutine(Signin()); });
        rv.siSignupB.onClick.AddListener(delegate { OpenSignup(); });
        rv.siSkipB.onClick.AddListener(delegate { });

        rv.siEmailIn.text = LoadManager.LoadEmail();
    }