Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         void Start()
         {
             BitmapFont purposeFont1 = new BitmapFont("Fonts/shop_font", "Fonts/shop_font_xml", purposeLabel1);
             BitmapFont purposeFont2 = new BitmapFont(purposeFont1, purposeLabel2);
             BitmapFont purposeFont3 = new BitmapFont(purposeFont1, purposeLabel3);

             purposeFont1.setText("5th place or better : 50 #", 0, 12, "GUI", "GUI");
             purposeFont2.setText("3rd place or better : 100 #", 0, 12, "GUI", "GUI");
             purposeFont3.setText("1st place : 200 #", 0, 12, "GUI", "GUI");

             purposeLabel1.transform.localScale = new Vector3(0.8f, 0.8f, purposeLabel1.transform.localScale.z);
             purposeLabel2.transform.localScale = new Vector3(0.8f, 0.8f, purposeLabel2.transform.localScale.z);
             purposeLabel3.transform.localScale = new Vector3(0.8f, 0.8f, purposeLabel3.transform.localScale.z);

             int star = Data.getData(Data.KEY_STAR + (Attr.currentWorld * 15 + Attr.currentLevel));
             for (int i = 0; i < 3; i++)
             {
                 if (i < star)
                 {
                     stars[i].GetComponent().sprite = starSprite;
                 }
             }

         }