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:

     public void OnGUI()
     {
         // alternatively to doing this calculation here:
         // calculate these values in Update() and make them publicly available to all other scripts
         double elapsedTime = (PhotonNetwork.time - StartTime);
         double remainingTime = SecondsPerTurn - (elapsedTime % SecondsPerTurn);
         int turn = (int)(elapsedTime / SecondsPerTurn);


         // simple gui for output
         GUILayout.BeginArea(TextPos);
         GUILayout.Label(string.Format("elapsed: {0:0.000}", elapsedTime));
         GUILayout.Label(string.Format("remaining: {0:0.000}", remainingTime));
         GUILayout.Label(string.Format("turn: {0:0}", turn));
         if (GUILayout.Button("new round"))
         {
             this.StartRoundNow();
         }
         GUILayout.EndArea();
     }