您使用广告拦截 (Adblock) 程序。
如果没有广告收入,
eWenda e问答将无法被维持。

恳请您关闭 Adblock

用户 Hi~ o(* ̄▽ ̄*)ブ

已登录: 2 月 (从 10月 21, 2021)
类型: 已注册用户
特权: 问题的投票
回答的投票
全名:
州属:
网站:
关于: Unity的Login和Register Account System

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LoginAndRegister : MonoBehaviour
{
    int account_quantity = 0;
    const string string_key = "A";
    [SerializeField] private Button Create_new_account;
    [SerializeField] private Button Login_account;
    [SerializeField] private Button Delete_all;
    [SerializeField] private InputField new_account_username;
    [SerializeField] private InputField new_account_password;
    [SerializeField] private InputField login_account_username;
    [SerializeField] private InputField login_account_password;

    string[] username;
    string[] password;
    void Start()
    {
        Create_new_account.onClick.AddListener(press);
        account_quantity = PlayerPrefs.GetInt(string_key);
        Delete_all.onClick.AddListener(Delete_all_m);
        Login_account.onClick.AddListener(Login_m);
        Debug.Log(account_quantity);
    }

    void press()
    {
        if (new_account_password.text.Length > 0 && new_account_username.text.Length > 0)
        {
            account_quantity += 1;
            PlayerPrefs.SetInt(string_key, account_quantity);
            Debug.Log(account_quantity);
            username = new string[account_quantity];
            password = new string[account_quantity];
            username[account_quantity - 1] = "Username" + account_quantity;
            password[account_quantity - 1] = "Password" + account_quantity;
            PlayerPrefs.SetString(username[account_quantity - 1], new_account_username.text);
            PlayerPrefs.SetString(password[account_quantity - 1], new_account_password.text);
            Debug.Log("Username : " + PlayerPrefs.GetString(username[account_quantity - 1]));
            Debug.Log("Username : " + PlayerPrefs.GetString(password[account_quantity - 1]));
        }
        else
        {
            Debug.Log("Pls insert some input");
        }
    }

    void Login_m()
    {
        for (int x = 0; x < account_quantity; x++)
        {
            if (login_account_username.text == PlayerPrefs.GetString(username[x]))
            {
                Debug.Log("Username is correct");
                if (login_account_password.text == PlayerPrefs.GetString(password[x]))
                {
                    Debug.Log("Password is correct");
                }
                else
                {
                    Debug.Log("password is wrong");
                }
                break;
            }
            else if (x == account_quantity - 1)
            {
                Debug.Log("Username is wrong");
            }
        }
    }


    void Delete_all_m()
    {
        PlayerPrefs.DeleteAll();
    }

    void Update()
    {
        username = new string[account_quantity];
        password = new string[account_quantity];
        for (int x = 0; x < account_quantity; x++)
        {
            username[x] = "Username" + (x + 1);
            password[x] = "Password" + (x + 1);
        }
    }

}

Hi~ o(* ̄▽ ̄*)ブ 的动态

目前积分: 2,030 分 (积分排名:62)
提问数: 14 (14 个已采纳)
回答: 27 (8 采纳)
评论: 63
投票给了: 3 问题, 1 回答
给出的评价: 4 赞成, 0 反对
收到的评价: 14 赞成, 3 反对

Hi~ o(* ̄▽ ̄*)ブ 的墙

登录 或者 注册 后再发此贴。
呵呵,不清楚
11月 30, 2021 用户: 学习的路虽然很艰难,至少你曾经努力过
我现在有一个问题
你是小学的还是中学的(头晕)
11月 28, 2021 用户: Adrian Chan Xian Wei
后面的号码是什么?
11月 27, 2021 用户: Hi~ o(* ̄▽ ̄*)ブ
我是llhm
11月 27, 2021 用户: LLHM
你给我你的Discord
11月 26, 2021 用户: Hi~ o(* ̄▽ ̄*)ブ
我有Block你?
11月 26, 2021 用户: Hi~ o(* ̄▽ ̄*)ブ
and... you blocked me... am not a hacker...
11月 26, 2021 用户: LLHM
THERE IS A HACKER IN DISCORD
11月 26, 2021 用户: LLHM
hi
11月 22, 2021 用户: Hi~ o(* ̄▽ ̄*)ブ
我比你早5天注册呵呵
11月 22, 2021 用户: 学习的路虽然很艰难,至少你曾经努力过
...