Я хочу составить список всех достижений, которые игрок может получить в моей игре.С помощью приведенного ниже кода я получаю достижения с сервера и создал список прокрутки в Unity, чтобы показать их, но появляется только первая строка.Я хотел бы показать имя, описание и валюту всех из них.Я также хотел бы изменить цвет достижений, полученных игроком, если переменная bool заработанная верна.
Я приложил ниже изображение списка, который я хотел бы видеть, и скриншот скролла, который у меня есть в иерархии.
new GameSparks.Api.Requests.LogEventRequest ()
.SetEventKey ("LISTACHIEVEMENTS")
.Send ((response) => {
if(!response.HasErrors)
{
Debug.Log("List Achivements Loaded Sucessfully...");
GSData scriptData = response.ScriptData;
List<GSData> achievements = scriptData.GetGSDataList("achievements"); //retrieve the array of objects
for (int i = 0; i < achievements.Count; i++)
{
string name = achievements[i].GetString("name");
string description = achievements[i].GetString("description");
int? currency1Award = achievements[i].GetInt("currency1Award");
bool? earned = achievements[i].GetBoolean("earned");
Debug.Log(name);
Debug.Log(description);
Debug.Log(currency1Award);
Debug.Log(earned);
GameObject tempFile = Instantiate (filePrefab, contentRef.transform);
Text tempName = tempFile.transform.GetChild(0).GetComponent<Text>();
Text tempDescription = tempFile.transform.GetChild(1).GetComponent<Text>();
Text tempCurrency1Award = tempFile.transform.GetChild(2).GetComponent<Text>();
tempName.text = name;
tempDescription.text = description;
tempCurrency1Award.text = currency1Award.ToString();
}
}
else
{
Debug.Log("Error Loading Achivements...");
}
});