Esempio n. 1
0
    private void OnClickSaveButton()
    {
        var nickname = NameField.text;

        if (nickname.Length == 0)
        {
            return;
        }

        GameScore gameScore = new GameScore
        {
            score      = _score,
            playerName = nickname
        };

        StartCoroutine(_leanCloud.Create("GameScore", JsonUtility.ToJson(gameScore, false), ShowRankPanel));
        SaveScorePanel.SetActive(false);
    }
Esempio n. 2
0
    /// <summary>
    /// 处理点击上传分数按钮
    /// </summary>
    void OnClickSaveButton()
    {
        var nickname = NameField.text;

        if (nickname.Length == 0)
        {
            return;
        }

        //创建一个GameScore分数对象
        GameScore gameScore = new GameScore();

        gameScore.score      = _score;
        gameScore.playerName = nickname;

        //异步保存
        StartCoroutine(_leanCloud.Create("GameScore", JsonUtility.ToJson(gameScore, false), ShowRankPanel));
        SaveScorePanel.SetActive(false);
    }
Esempio n. 3
0
    //处理点击上传分数按钮
    private void OnClickSaveButton()
    {
        //将名字输入框下的text组件赋值给字符串类型的变量
        var nickname = NameField.text;

        //检测到用户未输入任何字符串则结束本次方法的调用 需要用户填写后再次点击
        if (nickname.Length == 0)
        {
            return;
        }

        //创建一个GameScore分数对象 初始化
        GameScore gameScore = new GameScore
        {
            //将每次游戏的得分和每次的昵称赋值给云端数据库类的分数变量和用户名变量
            score      = _score,
            playerName = nickname
        };

        //通过封装好的SDK进行异步保存(不用等用户所有的操作都完成 就可以相应用户的请求)
        StartCoroutine(_leanCloud.Create("GameScore", JsonUtility.ToJson(gameScore, false), ShowRankPanel));
        //上传后关闭这个进行上传用户名和分数的面板
        SaveScorePanel.SetActive(false);
    }