Exemplo n.º 1
0
    private IEnumerator LoadGameHeaderArt()
    {
        string filePath = "";

        if (activeGame.gameType == LibraryGameType.Revive)
        {
            //Debug.Log(game.imagePath);
            string dir = Path.GetDirectoryName(activeGame.imagePath);

            if (File.Exists(Path.Combine(dir, "cover_square_image.jpg")))
            {
                //square image
                //byte[] imgData = File.ReadAllBytes(Path.Combine(dir, "cover_square_image.jpg"));
                filePath = Path.Combine(dir, "cover_square_image.jpg");
            }
        }
        else
        {
            //Load the image:
            string cachedImageName = activeGame.appID + "_header.jpg";
            filePath = Path.Combine(LibraryHelper.dpGamesLibraryImagePath, cachedImageName);

            if (!File.Exists(filePath))
            {
                string imgURL = @"https://steamcdn-a.akamaihd.net/steam/apps/" + activeGame.appID + "/header.jpg";
                yield return(LibraryHelper.DownloadImage(imgURL, filePath));
            }
        }

        ClearTexture();

        if (filePath == "")
        {
            yield break;
        }

        byte[]    imgData = File.ReadAllBytes(filePath);
        Texture2D tex     = new Texture2D(1, 1);

        tex.LoadImage(imgData);
        theBarCurrentGameArt.texture = tex;
    }