Ejemplo n.º 1
0
    //ユーザ名変更
    public static void changeName(string newName)
    {
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("user");

        query.WhereEqualTo("userName", getUserName());
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            //検索成功したら
            if (e == null)
            {
                //HighScoreのほうの名前も変える
                NCMBQuery <NCMBObject> query2 = new NCMBQuery <NCMBObject>("HighScore");
                query2.WhereEqualTo("userName", getUserName());
                query2.FindAsync((List <NCMBObject> objList2, NCMBException e2) =>
                {
                    if (e2 == null)
                    {
                        objList2[0]["userName"] = newName;
                        objList2[0].SaveAsync();
                    }
                });


                objList[0]["userName"] = newName;

                objList[0].SaveAsync((NCMBException se) =>
                {
                    if (e == null)
                    {
                        NCMBUser.LogInAsync(newName, PlayerInformation.password);
                    }
                });

                userName = newName;
                PlayerInformation.setNamePass(newName, PlayerInformation.password);
                PhotonNetwork.playerName = newName;

                ChangeUserName.setMessage("変更しました");
            }
            else
            {
                ChangeUserName.setMessage("エラー" + e.ErrorCode + ":" + e.Message);
                return;
            }
        });
    }