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:

     private static void ImportWin8Support()
     {
         if (EditorApplication.isCompiling || EditorApplication.isPlayingOrWillChangePlaymode)
         {
             return; // don't import while compiling
         }

         #if UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_5_1 || UNITY_5_2
         const string win8Package = "Assets/Plugins/Photon3Unity3D-Win8.unitypackage";

         bool win8LibsExist = File.Exists("Assets/Plugins/WP8/Photon3Unity3D.dll") && File.Exists("Assets/Plugins/Metro/Photon3Unity3D.dll");
         if (!win8LibsExist && File.Exists(win8Package))
         {
             AssetDatabase.ImportPackage(win8Package, false);
         }
         #endif
     }