Snaparazzi/Assets/Scripts/PropositionHandler.cs
2024-01-28 22:42:02 +01:00

36 lines
1.1 KiB
C#

using Firebase.Database;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PropositionHandler : MonoBehaviour
{
public GameManager gameManager;
public StorageManager storageManager;
public TextMeshProUGUI promptLabel;
public PromptList prompts;
public Image[] btns;
public void ShowQuestion(Question currentQuestion)
{
List<Proposition> props = currentQuestion.propositions.Values.ToList();
promptLabel.text = prompts.GetPromptById(currentQuestion.promptId).en;
for (int i = 0; i < 2; i++)
{
StorageManager.ConvertGoogleStorageURLToHttpsUrl(props[i].photoUrl, _httpURL =>
{
StartCoroutine(StorageManager.DownloadImage_Coroutine(_httpURL, (Texture texture) =>
{
Sprite sprite = Sprite.Create(texture as Texture2D, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
btns[i].sprite = sprite;
}));
});
}
}
}