コード例 #1
0
    /// <summary>
    /// Takes a word string and retrieves all of the png images associated with it.
    /// </summary>
    /// <param name="word"></param>///
    /// <returns>bool</returns>
    public bool RetrieveSavedPics(string word)
    {
        Debug.Log("MOD: trying to retirieve pictures for word " + word);
        int x = 1;

        List <byte[]> tempList = FileAccessUtil.RetrieveWordPics(word);

        /****************************************************************/
        // THIS IS USED TO DISPLAY MULTIPLE STOCK IMAGES
        // Grab any stock textures from assets

        if (stockTextureList.Count == 0)
        {
            Texture2D stockChecker = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "1");

            if (stockChecker != null)
            {
                Debug.Log("Stock images exist for: " + word);
                Texture2D stockTexture1 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "1");
                Texture2D stockTexture2 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "2");
                Texture2D stockTexture3 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "3");
                Texture2D stockTexture4 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "4");
                Texture2D stockTexture5 = Resources.Load <Texture2D>("WordPictures/" + word + "/" + word + "5");

                stockTextureList.Add(stockTexture1);
                stockTextureList.Add(stockTexture2);
                stockTextureList.Add(stockTexture3);
                stockTextureList.Add(stockTexture4);
                stockTextureList.Add(stockTexture5);
            }
            else
            {
                Debug.Log("no stock images exist for " + word);
            }
        }


        if (tempList != null && tempList.Count > 0)
        {
            foreach (byte[] bytes in tempList)
            {
                if (bytes == null || bytes.Length <= 0)
                {
                    Debug.Log("MOD: BYTES ARE NO GOOOOOOD");
                }

                Debug.Log("MOD: IN FOR EACH x IS " + x.ToString());

                Texture2D tempTex = new Texture2D(SAVED_PIC_XY, SAVED_PIC_XY);
                tempTex.LoadImage(bytes);
                textureList.Add(tempTex);
                x += 1;
            }
        }
        else
        {
            return(false);
        }

        string[] isolatedName;

        foreach (string fileName in FileAccessUtil.GetWordImagePaths(word))
        {
            isolatedName = Regex.Split(fileName, PNG_PATTERN);
            Debug.Log("REGEX: isolated name is " + isolatedName[1]);
            if (!wordImageNames.Contains(isolatedName[1]))
            {
                wordImageNames.Add(isolatedName[1]);
            }
        }

        foreach (string fileName in wordImageNames)
        {
            Debug.Log("Next word image name is " + fileName);
        }



        Debug.Log("MOD: TEX LIST COUNT IS " + textureList.Count.ToString());
        return(true);
    }