- Home /
PlayFab: Getting player title data with leaderboard?
I have a player title data key I want to get as I get the leaderboard data. Right now, all the leaderboard stuff works, and I can print the data key values, but I'm not sure how to apply those values to the instantiated leaderboard entry prefabs, as they are instantiated within the "OnLeaderboardTimeTrialsGet" and not the "SendOtherPlayersEquippedShip".
void OnLeaderboardTimeTrialsGet(GetLeaderboardResult result)
{
foreach (var item in result.Leaderboard)
{
GameObject newGo = Instantiate(ttPrefab, ttParent);
//Changing text of the "ttPrefab" to show display name, score, etc
string playerId = item.PlayFabId;
GetOtherUserShipTTEntry(playerId);
{
}
public void GetOtherUserShipTTEntry(string id)
{
PlayFabClientAPI.GetUserData(new GetUserDataRequest()
{
PlayFabId = id,
Keys = null
}, result =>
{
foreach (var item in result.Data)
{
int shipEntry = 0;
if (result.Data != null)
{
shipEntry = int.Parse(result.Data["Ship"].Value);
}
else
{
shipEntry = 0;
}
SendOtherPlayersEquippedShip(shipEntry + 6);
Debug.Log(shipEntry);
}
}, error => { });
}
public void SendOtherPlayersEquippedShip(int entry)
{
foreach (var child in ttParent)
{
GameObject shipImage = child as GameObject;
if (entry == null)
entry = 0;
GameObject shipChild = shipImage.transform.GetChild(entry).gameObject;
shipChild.SetActive(true);
}
}
The ttPrefab is a UI gameobject with 3 text children for name, score, and position. It also has images of ships I want to display based on what the player title data key returned. Right now I get the:
NullReferenceException: Object reference not set to an instance of an object
error, which makes sense. I'm just not sure how to fix it.
Your answer
Follow this Question
Related Questions
Is there any way to delete the Steamworks leaderboard? 1 Answer
How can I load every score from the leaderboard? 0 Answers
Google Play Games Services- Leaderboard Problem 0 Answers
Prevous score value for leaderboard in GameCenter 0 Answers
Leaderboard LogIn() method not returning success/failure 0 Answers