MemeTexter/Assets/Scripts/GlobalGallery.cs
/// <summary>
/// Fills the global meme gallery with memes from Resources/MemeFiles/MemeData.txt
/// </summary>
Fills the global meme gallery with memes from Resources/MemeFiles/MemeData.txt
Fills the global meme gallery with memes from Resources / MemeFiles / MemeData . txt
private static void FillGlobalGallery()
    {
        TextAsset textFile = (TextAsset)Resources.Load("MemeFiles/MemeData");
        string[] lines = textFile.text.Split("\n"[0]);
        for (int i = 0; i < lines.Length; i++)
        {
            string[] memeData = lines[i].Split(","[0]);
            if (memeData.Length == 4)
            {
                string title = memeData[0].Trim();
                string creator = memeData[1].Trim();
                string type = memeData[2].Trim();
                string imageFile = memeData[3].Trim();
                Meme.MemeType memeType = Meme.MemeType.Max;
                bool validMeme = true;
                if (type == "DeepFried")
                {
                    memeType = Meme.MemeType.DeepFried;
                }
                else if (type == "Text")
                {
                    memeType = Meme.MemeType.Text;
                }
                else if (type == "Reaction")
                {
                    memeType = Meme.MemeType.Reaction;
                }
                else
                {
                    validMeme = false;
                }
                Sprite imageSprite = Resources.Load<Sprite>("MemeFiles/" + imageFile);
                if (validMeme)
                {
                    Meme newMeme = new Meme(title, creator, memeType, imageSprite);
                    globalGallery.Add(newMeme);
                }
            }
        }
    }
private static void FillGlobalGallery ( ) { TextAsset textFile = ( TextAsset ) Resources . Load ( " " ) ; string [ ] lines = textFile . text . Split ( " \n " [ 0 ] ) ; for ( int i = 0 ; i < lines . Length ; i ++ ) { string [ ] memeData = lines [ i ] . Split ( " " [ 0 ] ) ; if ( memeData . Length == 4 ) { string title = memeData [ 0 ] . Trim ( ) ; string creator = memeData [ 1 ] . Trim ( ) ; string type = memeData [ 2 ] . Trim ( ) ; string imageFile = memeData [ 3 ] . Trim ( ) ; Meme . MemeType memeType = Meme . MemeType . Max ; bool validMeme = true ; if ( type == " " ) { memeType = Meme . MemeType . DeepFried ; } else if ( type == " " ) { memeType = Meme . MemeType . Text ; } else if ( type == " " ) { memeType = Meme . MemeType . Reaction ; } else { validMeme = false ; } Sprite imageSprite = Resources . Load < Sprite > ( " " + imageFile ) ; if ( validMeme ) { Meme newMeme = new Meme ( title , creator , memeType , imageSprite ) ; globalGallery . Add ( newMeme ) ; } } } }
Fills the global meme gallery with memes from Resources/MemeFiles/MemeData.txt
Fills the global meme gallery with memes from Resources / MemeFiles / MemeData . txt
// For each line in MemeData.txt... // If the line has the correct number of arguments... // Parse the comma-separated line // Select the appropriate type // Find the image