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:

     protected virtual void OnGuiRegisterCloudApp()
     {
         GUI.skin.label.wordWrap = true;
         if (!this.isSetupWizard)
         {
             GUILayout.BeginHorizontal();
             GUILayout.FlexibleSpace();
             if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false)))
             {
                 this.SwitchMenuState(GUIState.Main);
             }

             GUILayout.EndHorizontal();

             GUILayout.Space(15);
         }

         if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud)
         {
             GUI.skin.label.fontStyle = FontStyle.Bold;
             GUILayout.Label(CurrentLang.ConnectButton);
             EditorGUILayout.Separator();
             GUI.skin.label.fontStyle = FontStyle.Normal;

             GUILayout.Label(CurrentLang.UsePhotonLabel);
             EditorGUILayout.Separator();
             this.emailAddress = EditorGUILayout.TextField(CurrentLang.EmailLabel, this.emailAddress);

             if (GUILayout.Button(CurrentLang.SendButton))
             {
                 GUIUtility.keyboardControl = 0;
                 this.RegisterWithEmail(this.emailAddress);
             }

             GUILayout.Space(20);


             GUILayout.Label(CurrentLang.SignedUpAlreadyLabel);
             if (GUILayout.Button(CurrentLang.SetupButton))
             {
                 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
             }
             EditorGUILayout.Separator();


             GUILayout.Label(CurrentLang.RegisterByWebsiteLabel);
             if (GUILayout.Button(CurrentLang.AccountWebsiteButton))
             {
                 EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress));
             }

             EditorGUILayout.Separator();

             GUILayout.Label(CurrentLang.SelfHostLabel);

             if (GUILayout.Button(CurrentLang.SelfHostSettingsButton))
             {
                 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
             }

             GUILayout.FlexibleSpace();


             if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
             {
                 GUILayout.Label(CurrentLang.MobileExportNoteLabel);
             }
             EditorGUILayout.Separator();
         }
         else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered)
         {
             GUI.skin.label.fontStyle = FontStyle.Bold;
             GUILayout.Label(CurrentLang.OopsLabel);
             GUI.skin.label.fontStyle = FontStyle.Normal;

             GUILayout.Label(CurrentLang.EmailInUseLabel);

             if (GUILayout.Button(CurrentLang.SeeMyAccountPageButton))
             {
                 EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
             }

             EditorGUILayout.Separator();

             GUILayout.Label(CurrentLang.KnownAppIdLabel);
             GUILayout.BeginHorizontal();
             if (GUILayout.Button(CurrentLang.CancelButton))
             {
                 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
             }

             if (GUILayout.Button(CurrentLang.SetupButton))
             {
                 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
             }

             GUILayout.EndHorizontal();
         }
         else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud)
         {
             // cloud setup
             GUI.skin.label.fontStyle = FontStyle.Bold;
             GUILayout.Label(CurrentLang.PhotonCloudConnect);
             GUI.skin.label.fontStyle = FontStyle.Normal;

             EditorGUILayout.Separator();
             this.OnGuiSetupCloudAppId();
             this.OnGuiCompareAndHelpOptions();
         }
         else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted)
         {
             // self-hosting setup
             GUI.skin.label.fontStyle = FontStyle.Bold;
             GUILayout.Label(CurrentLang.SetupOwnHostLabel);
             GUI.skin.label.fontStyle = FontStyle.Normal;

             EditorGUILayout.Separator();

             this.OnGuiSetupSelfhosting();
             this.OnGuiCompareAndHelpOptions();
         }
     }