void GetImagesOffline() { totalPuzzleAmount = puzzleImageList.Count; int amount = 4 + Mathf.Clamp(controlUI.packsCargados, 0, 1); while (controlUI.posicionPrimero + amount > totalPuzzleAmount) { amount--; if (amount <= 0) { Debug.Log("It's trying to load more puzzles than we have."); } } for (int i = controlUI.posicionPrimero; i < controlUI.posicionPrimero + amount; i++) { if (i > totalPuzzleAmount - 1) { break; } controlUI.TextureToButtonDirect(i, puzzleImageList[i]); } controlUI.ActivarAnimBoton(); }
IEnumerator DescargarPack() { int cantidad = 4 + Mathf.Clamp(controlUI.packsCargados, 0, 1); //如果你开始离线,没有列表,这里有互联网下载 if (!connectInternet && CheckInternet()) { LoadingList(); yield break; } while (controlUI.posicionPrimero + cantidad > countPuzzlesTotal) { cantidad--; if (cantidad <= 0) { Debug.Log("Its trying to load more puzzles than we have."); } } for (int i = controlUI.posicionPrimero; i < controlUI.posicionPrimero + cantidad; i++) { if (i > countPuzzlesTotal - 1) { break; } if (CheckInternet() && PlayerPrefs.GetString("puzzleGuard" + i, "") == "") { remoteImageList[i] = remoteImageList[i].Trim(); wwwImage[i] = new WWW(remoteImageList[i]); StartCoroutine(LimiteTiempoDescarga(i)); yield return(wwwImage[i]); if (descargaTimedOut || !string.IsNullOrEmpty(wwwImage[i].error)) { if (!string.IsNullOrEmpty(wwwImage[i].error)) { Debug.Log("Download error: " + wwwImage[i].error + ". Image " + i + " has not been loaded."); } else { Debug.Log("It took so long to load. Image " + i + " has not been loaded."); } descargaTimedOut = false; for (int borrarErrores = i - 1; borrarErrores >= controlUI.posicionPrimero; borrarErrores--) { //按照下标删除 puzzleImageList.RemoveAt(borrarErrores); controlUI.imagenPuzzleGrises.RemoveAt(borrarErrores); } controlUI.ErrorDuranteDescarga(); yield break; } Debug.Log("Downloading image " + i + " from that link: " + remoteImageList[i]); WriteTextureToPlayerPrefs(i, wwwImage[i].texture); puzzleImageList.Add(wwwImage[i].texture); controlUI.TexturaABoton(i, puzzleImageList[i]); } else { if (PlayerPrefs.GetString("puzzleGuard" + i, "") != "") { puzzleImageList.Add(LoadImagenPlayerPrefs(i)); Debug.Log("Image " + i + " loaded from prefs."); controlUI.TexturaABoton(i, puzzleImageList[i]); } else { Debug.Log("There is no internet nor a saved image. This should never happen."); } } yield return(null); } controlUI.ActivarAnimBoton(); }