我在用playfab做主板方面有问题,我不知道如何把我的游戏分数送到Playfab的主板上
我在c#并不专业,这也是为什么我必须看Code才能知道如何轻松地成为排行榜的原因。
我的密码:
这是我的分数代码,它允许我每次从墙上的分数中得到分数号:
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:
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");
}
}发布于 2022-11-25 21:39:38
转到Playfab网站->进入您的游戏工作室->在那里单击设置图标->获得“标题设置”->单击选项卡API功能->从标题启用API功能->启用“允许客户端启用统计”->保存
https://stackoverflow.com/questions/73973113
复制相似问题