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 NewSceneLoaded()
     {
         if (this.loadingLevelAndPausedNetwork)
         {
             this.loadingLevelAndPausedNetwork = false;
             PhotonNetwork.isMessageQueueRunning = true;
         }
         // Debug.Log("OnLevelWasLoaded photonViewList.Count: " + photonViewList.Count); // Exit Games internal log

         List removeKeys = new List();
         foreach (KeyValuePair kvp in this.photonViewList)
         {
             PhotonView view = kvp.Value;
             if (view == null)
             {
                 removeKeys.Add(kvp.Key);
             }
         }

         for (int index = 0; index < removeKeys.Count; index++)
         {
             int key = removeKeys[index];
             this.photonViewList.Remove(key);
         }

         if (removeKeys.Count > 0)
         {
             if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                 Debug.Log("New level loaded. Removed " + removeKeys.Count + " scene view IDs from last level.");
         }
     }