feat: download image on proposition

This commit is contained in:
Michel Roux 2024-01-28 17:34:11 +01:00
parent b5e8c910a2
commit 4e2ce97cd2
3 changed files with 53 additions and 2 deletions

View File

@ -13,7 +13,7 @@ public class Room
[JsonConverter(typeof(ArrayToDictionaryConverter<Question>))]
public Dictionary<int, Question> questions;
public Dictionary<string, Player> players;
public string currentQuestionId;
public int currentQuestionId;
public double creationDate;
public int currentState;
@ -23,7 +23,7 @@ public Room(string _code)
creationDate = DateTime.Now.ToOADate();
players = new Dictionary<string, Player>();
questions = new Dictionary<int, Question>();
currentQuestionId = "";
currentQuestionId = 0;
currentState = 1; //default by PC
}

View File

@ -0,0 +1,40 @@
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++) {
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()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 02c0fa5c3e6cb4ce29942d8cb857076e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: