首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向Playfab发送C# Unity中的领导板

向Playfab发送C# Unity中的领导板
EN

Stack Overflow用户
提问于 2022-10-06 11:34:03
回答 1查看 65关注 0票数 0

我在用playfab做主板方面有问题,我不知道如何把我的游戏分数送到Playfab的主板上

我在c#并不专业,这也是为什么我必须看Code才能知道如何轻松地成为排行榜的原因。

我的密码:

这是我的分数代码,它允许我每次从墙上的分数中得到分数号:

代码语言:javascript
复制
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class score : MonoBehaviour
{

public static int Score = 0;

void Start()
{
    Score = 0;

}

void Update()
{
    GetComponent<UnityEngine.UI.Text>().text = Score.ToString();
}
}

这是我的playfab代码PlayFabManager:

代码语言:javascript
复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;

public class PlayFabManager : MonoBehaviour
{

void Start()
{

    Login();
}

void Login()
{
    var request = new LoginWithCustomIDRequest
    {
        CustomId = SystemInfo.deviceUniqueIdentifier,
        CreateAccount = true
    };
    PlayFabClientAPI.LoginWithCustomID(request, OnSuccess, OnError);
}

void OnSuccess(LoginResult result)
{
    Debug.Log("Success login/account create!");
}

void OnError(PlayFabError error)
{
    Debug.Log("Error while logging in/creating account!");
    Debug.Log(error.GenerateErrorReport());
}

public void SendLeaderboard(int score)
{
    var request = new UpdatePlayerStatisticsRequest
    {
        Statistics = new List<StatisticUpdate>
        {
            new StatisticUpdate
            {
                StatisticName = "PlatFormScore",
                Value = score
            }

        }
    };
    PlayFabClientAPI.UpdatePlayerStatistics(request, OnLeaderboardUpdate, OnError);
}
void OnLeaderboardUpdate(UpdatePlayerStatisticsResult result)
{
    Debug.Log("Successfull leaderboard send");
}


}
EN

回答 1

Stack Overflow用户

发布于 2022-11-25 21:39:38

转到Playfab网站->进入您的游戏工作室->在那里单击设置图标->获得“标题设置”->单击选项卡API功能->从标题启用API功能->启用“允许客户端启用统计”->保存

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73973113

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档