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:

     // called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues)
     private static void EditorUpdate()
     {
         if (dontCheckPunSetup || PhotonEditor.Current == null)
         {
             return;
         }

         // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set
         if (!PhotonEditor.Current.DisableAutoOpenWizard && PhotonEditor.Current.HostType == ServerSettings.HostingOption.NotSet)
         {
             ShowRegistrationWizard();
         }

         // Workaround for TCP crash. Plus this surpresses any other recompile errors.
         if (EditorApplication.isCompiling)
         {
             if (PhotonNetwork.connected)
             {
                 if (lastWarning > EditorApplication.timeSinceStartup - 3)
                 {
                     // Prevent error spam
                     Debug.LogWarning(CurrentLang.WarningPhotonDisconnect);
                     lastWarning = EditorApplication.timeSinceStartup;
                 }

                 PhotonNetwork.Disconnect();
             }
         }
     }