From 5f0704c2f11bba4ad86882ab5b98ac2d8bb73266 Mon Sep 17 00:00:00 2001 From: Fangh Date: Sun, 4 Feb 2024 13:36:03 +0100 Subject: [PATCH] fix: manage if one player did not send a propositon --- Assets/Scripts/PropositionHandler.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/PropositionHandler.cs b/Assets/Scripts/PropositionHandler.cs index 5542af2..2e80919 100644 --- a/Assets/Scripts/PropositionHandler.cs +++ b/Assets/Scripts/PropositionHandler.cs @@ -16,7 +16,6 @@ public class PropositionHandler : MonoBehaviour public void ShowQuestion(Question currentQuestion) { - List props = currentQuestion.propositions.Values.ToList(); string enPrompt = prompts.GetPromptById(currentQuestion.promptId).en; promptLabel.text = enPrompt; @@ -24,14 +23,21 @@ public void ShowQuestion(Question currentQuestion) for (int i = 0; i < 2; i++) { int index = i; // Capture la valeur de i pour cette itération - StorageManager.ConvertGoogleStorageURLToHttpsUrl(props[i].photoUrl, _httpURL => + if(props[i].photoUrl == null) { - StartCoroutine(StorageManager.DownloadImage_Coroutine(_httpURL, (Texture texture) => + Debug.Log("One player did not send a proposition !", this); + } + else + { + StorageManager.ConvertGoogleStorageURLToHttpsUrl(props[i].photoUrl, _httpURL => { - Sprite sprite = Sprite.Create(texture as Texture2D, new Rect(0, 0, texture.width, texture.height), Vector2.zero); - btns[index].sprite = sprite; // Utilise l'index local au lieu de i - })); - }); + 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[index].sprite = sprite; // Utilise l'index local au lieu de i + })); + }); + } } }