private void CreateNewWishObject(WishData wish) { if (cardPrefab == null) { Debug.LogError("Card Prefab reference missing"); return; } List <GameObject> availableCards = new List <GameObject>(); foreach (GameObject GO in allWishPositions) { if (GO.activeSelf == false) { availableCards.Add(GO); } } if (availableCards.Count == 0) { Debug.LogError("Not enough empty card positions"); } else { int rand = UnityEngine.Random.Range(0, availableCards.Count); allWishCards.Add(wish, Instantiate(cardPrefab, availableCards[rand].transform).GetComponent <WishCard>()); allWishCards[wish].Text.text = wish.userText; allWishCards[wish].Mat.SetColor("_MainColor", wish.color); availableCards[rand].SetActive(true); } }
public void CreatePlayersWishObject(WishData wish) { allWishCards.Add(wish, Instantiate(cardPrefab, playersCustomPos.transform).GetComponent <WishCard>()); allWishCards[wish].Text.text = wish.userText; allWishCards[wish].Mat.SetColor("_MainColor", wish.color); playersCustomPos.SetActive(true); }
private void GetDataFromCloud(string uID) { FirebaseStorage storage = FirebaseStorage.DefaultInstance; StorageReference storage_ref = storage.GetReferenceFromUrl(networkURL); string path = Directory.GetCurrentDirectory() + "\\" + folderName + "\\" + "TempData.txt"; ValidateDirectory(); ValidateFile("TempData.txt"); StorageReference fileRef = storage_ref.Child($"TanabataData/{uID}/{fileName}"); // Download to the local file system fileRef.GetFileAsync(path).ContinueWith(task => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("Stranger File downloaded."); } else { Debug.Log(task.Exception.ToString()); } expectedStrangerDataCount--; if (expectedStrangerDataCount == 0) { strangerDataDownloaded = true; } List <WishData> data = JsonConvert.DeserializeObject <List <WishData> >(File.ReadAllText(path)); if (data == null) { } else if (data.Count > 1) { //WishData f**k = data[UnityEngine.Random.Range(0, data.Count)]; WishData f**k = data[0]; allWishData.Add(f**k); } else { allWishData.Add(data[0]); } }); }