private void EditEndHandler(string str)
 {
     if (str == string.Empty)
     {
         str            = nameTool.getName();
         nameInput.text = str;
     }
     LocalStorage.SetString("name", str);
 }
    // Start is called before the first frame update
    void Start()
    {
        introduction.gameObject.SetActive(false);
        // 读表
        Role role;

        role.roleId        = 1;
        role.name          = "调皮镜";
        role.ackId         = (int)SkillEunm.SkillID.normalAck;
        role.ackDescribe   = "发射光线";
        role.skillId       = (int)SkillEunm.SkillID.groupChaos;
        role.skillDescribe = "颠倒方向";
        roles.Add(role);

        role.roleId        = 2;
        role.name          = "智慧镜";
        role.ackId         = (int)SkillEunm.SkillID.normalAck;
        role.ackDescribe   = "发射光线";
        role.skillId       = (int)SkillEunm.SkillID.fiveThunder;
        role.skillDescribe = "直接伤害";
        roles.Add(role);

        role.roleId        = 3;
        role.name          = "活泼镜";
        role.ackId         = (int)SkillEunm.SkillID.normalAck;
        role.ackDescribe   = "发射光线";
        role.skillId       = (int)SkillEunm.SkillID.protectiveCover;
        role.skillDescribe = "护盾防御";
        roles.Add(role);

        role.roleId        = 4;
        role.name          = "邪恶镜";
        role.ackId         = (int)SkillEunm.SkillID.normalAck;
        role.ackDescribe   = "发射光线";
        role.skillId       = (int)SkillEunm.SkillID.nightBringer;
        role.skillDescribe = "限制视野";
        roles.Add(role);

        nameTool        = GetComponent <NameTool>();
        audioController = GetComponent <AudioController>();
        audioController.BGMPlay(AudioEunm.mainBGM, 0.8f);
        instance = this;
        for (int i = 0; i < roleBtns.Length; ++i)
        {
            int index = i;
            indexs.Add(index);
            roleBtns[i].onClick.AddListener(
                delegate()
            {
                onClickHandler(index);
            }
                );
        }
        nameInput.onEndEdit.AddListener(EditEndHandler);
        if (LocalStorage.GetString("name") == string.Empty)
        {
            string name = nameTool.getName();
            nameInput.text = name;
            LocalStorage.SetString("name", name);
        }
        else
        {
            nameInput.text = LocalStorage.GetString("name");
        }
        if (GameData.user == null)
        {
            // 没有UUID,第一次登陆
            if (LocalStorage.GetString("UUID") == string.Empty)
            {
                // 生成UUID,发射给服务端,服务端返回UUID以及ID,然后记录下来
                string uuid = System.Guid.NewGuid().ToString();
                LocalStorage.SetString("UUID", uuid);
                LocalStorage.SetInt("ROLE", selectIndex);
                UserDTO user = new UserDTO();
                user.Id   = -1;
                user.Uuid = uuid;
                this.WriteMessage((int)MsgTypes.TypeLogin, (int)LoginTypes.LoginCreq, user.ToByteArray());
            }
            else
            {
                selectIndex = LocalStorage.GetInt("ROLE");
                UserDTO user = new UserDTO();
                user.Id   = -1;
                user.Uuid = LocalStorage.GetString("UUID");
                this.WriteMessage((int)MsgTypes.TypeLogin, (int)LoginTypes.LoginCreq, user.ToByteArray());
            }
        }
        else
        {
            selectIndex = LocalStorage.GetInt("ROLE");
            if (GameData.match)
            {
                Match();
            }
        }
        onClickHandler(selectIndex);
    }