Snaparazzi/Assets/Scripts/PropositionHandler.cs
2024-01-28 17:35:11 +01:00

43 lines
960 B
C#

using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class PropositionDownload : MonoBehaviour
{
public GameManager gameManager;
public StorageManager storageManager;
public Image[] btns;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnEnable()
{
List<Proposition> props = gameManager.myRoom.questions[gameManager.myRoom.currentQuestionId].propositions.Values.ToList();
for (int i = 0; i < 2; i++)
{
StartCoroutine(storageManager.DownloadImage(props[i].photoUrl, (Texture texture) =>
{
Sprite sprite = Sprite.Create(texture as Texture2D, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
btns[i].sprite = sprite;
}));
}
}
void OnDisable()
{
}
}