首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mac x设备上的统一主板- Pubnub,Playfab还是Firebase?

mac x设备上的统一主板- Pubnub,Playfab还是Firebase?
EN

Stack Overflow用户
提问于 2021-03-11 12:58:15
回答 1查看 233关注 0票数 1

我目前正在为我的Mac统一游戏制作一个主板功能。我第一次尝试Playfab,但一直收到一个错误,上面写着"PlayFabException:必须登录才能调用此方法PlayFab“。我找不到解决这个问题的办法。

我有两个脚本可以这样做,这是PlayFabManger脚本的代码:

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

    public class PlayFabManager : MonoBehaviour

    //public static PlayFabManager instance;
    // Start is called before the first frame update
    void Start()
    {
        //instance = this;
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            /*
            Please change the titleId below to your own titleId from PlayFab Game Manager.
            If you have already set the value in the Editor Extensions, this can be skipped.
            */
            PlayFabSettings.staticSettings.TitleId = "F9F3D";
        }
        Login();
    }

    // Update is called once per frame
    void Update()
    {

    }

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

    //private void OnLoginSuccess(LoginResult result)
    //{
    //    //>> Call Client API here <<
    //    var getStoreItemsRequest = new GetStoreItemsRequest { StoreId = "[YourStoreId]" };// Please change this value to your own storeId from PlayFab Game Manager
    //    PlayFabClientAPI.GetStoreItems(getStoreItemsRequest, OnGetSuccess, OnError);

    //}


    void OnSuccess(LoginResult result)
    {
        print("Successful login create");
    }

    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)
    {
        print("Successful leaderboard sent");
    }

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

    public void GetLeaderBoard()
    {
        var request = new GetLeaderboardRequest
        {
            StatisticName = "PlatformScore",
            StartPosition = 0,
            MaxResultsCount = 10
        };
        PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError);
    }

    private void OnLeaderboardGet(GetLeaderboardResult result)
    {
        foreach (var item in result.Leaderboard)
        {
            print(item.Position + " " + item.PlayFabId + " " + item.StatValue);
        }
    }

    }

`

我在另一个脚本中也有一行代码,它在start方法中调用,并引用上面的脚本,其中我传入了一个Playerprefs.GetInt变量:playFabManager.SendLeaderBoard(PlayerPrefs.GetInt("TtlPoints"));

有人知道如何解决这个错误吗?在Mac上,是否有更简单的方法可以使用其他扩展(如firebase或pubnub )来实现这一主板功能?

对不起,我的英语,期待着收到你的来信。

EN

回答 1

Stack Overflow用户

发布于 2021-03-15 20:49:10

我来接火基地的电话。

如果使用Firebase路由,则没有开箱即用的主板解决方案。有一个示例开放源码存储库,您可以使用它来实现实时数据库上的主板,实现起来应该相对简单。

您的第二个问题是,虽然实时数据库确实在桌面上工作(特别是领导板没有给我任何问题),但特性仅供开发期间使用。。如果您提交了一个相关的bug,该团队将致力于修复它,但它可能会被优先考虑在任何移动特性。您可以直接使用休息 API来实现它,但此时官方的统一示例和文档并不适用。

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

https://stackoverflow.com/questions/66583045

复制
相关文章

相似问题

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