예제 #1
0
 public bool RoutineChecks()
 {
     if (BuildSettings.Get.packExtension && BuildSettings.Get.updateExtension && !File.Exists(BuildSettings.Get.pemFile))
     {
         ShowNotification(new GUIContent(".pem file not found. Select file or disable the pack extension option."));
         return(false);
     }
     if (BuildSettings.Get.shortName == "" && PlayerSettings.productName.Length > 0)
     {
         BuildSettings.Get.shortName = PlayerSettings.productName.Substring(0, Mathf.Min(PlayerSettings.productName.Length, 12));
     }
     if (ChromeHelper.GetChromeLocation() == "")
     {
         if (EditorUtility.DisplayDialog("Chrome not found", "We can't seem to find Google Chrome on your system. would you like to manually search for it?", "Browse...", "Cancel"))
         {
             string chromeExe = EditorUtility.OpenFilePanel("Select chrome.exe", System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles), "exe");
             if (File.Exists(chromeExe) && Path.GetFileName(chromeExe) == "chrome.exe")
             {
                 EditorPrefs.SetString("ChromeExeLocation", chromeExe);
             }
             else
             {
                 ShowNotification(new GUIContent("Invalid chrome executable"));
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
        public static void BuildPlayer(bool run = false)
        {
            //Just in case, we save the settings
            BuildSettings.Save();

            string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", EditorUserBuildSettings.GetBuildLocation(BuildTarget.WebGL), "");

            if (Directory.Exists(path))
            {
                ProgressHelper progress = new ProgressHelper();
                progress.Reset(5);


                //Set Template
                string lastUsedTemplate = TemplateManager.SetChromeTemplate("PROJECT:ChromeApp");
                //Define symbols
                Builder.SetDefineSymbol(true);
                //Create subfolder
                path = Builder.CreateSubFolder(path);

                progress.SetCleanupCallback(() => {
                    //Clean up
                    //Reset Webgl template
                    TemplateManager.SetChromeTemplate(lastUsedTemplate);
                    //Define symbols
                    Builder.SetDefineSymbol(false);
                });
                //BUILD
                if (!Builder.BuildPlayer(path))
                {
                    progress.Done();
                    return;
                }
                //Process template
                progress.Step("Building Player - Chrome App", "Postprocessing Template Variables");
                TemplateManager.ProcessTemplateFiles(path);
                //Creatig Icons
                progress.Step("Building Player - Chrome App", "Creating icons");
                Icons.CreateIcons(path);
                //Creating Manifest
                progress.Step("Building Player - Chrome App", "Creating manifest");
                Manifest.CreateManifestFile(path);
                //Packing Extention
                progress.Step("Building Player - Chrome App", "Packing Extension into .crx file");
                if (BuildSettings.Get.packExtension)
                {
                    if (!ChromeHelper.PackExtension(path))
                    {
                        Debug.LogWarning("Chrome app was not packed into a .crx file.");
                    }
                }
                //launch player or reveal in explorer
                progress.Step("Building Player - Chrome App", "Launching");
                if (run)
                {
                    if (File.Exists(path + ".crx"))
                    {
                        CrxHeader header = new CrxHeader(path + ".crx");
                        Manifest.AddKeyToManifest(Path.Combine(path, "manifest.json"), header.PublicKey);
                    }
                    ChromeHelper.LoadAndRunExtension(path);
                }
                else
                {
                    EditorUtility.RevealInFinder(path);
                }
                //Clear progress and cleanup
                progress.Done();
            }
        }
예제 #3
0
        void PublishSectionGUI()
        {
            if (BeginSettingsBox(6, new GUIContent("Publishing Settings")))
            {
                GUILayout.Label("WebGL", EditorStyles.boldLabel, new GUILayoutOption[0]);
                GUI.changed     = false;
                WebGLMemorySize = EditorGUILayout.IntField("WebGL Memory Size*", WebGLMemorySize);
                if (GUI.changed)
                {
                    WebGLMemorySize = Mathf.Clamp(WebGLMemorySize, 0x10, 0x7ff);
                    PlayerSettings.WebGL.memorySize = WebGLMemorySize;
                }
                GUI.changed           = false;
                WebGLExceptionSupport = (WebGLExceptionSupport)EditorGUILayout.EnumPopup("Enable Exceptions*", PlayerSettings.WebGL.exceptionSupport);
                if (WebGLExceptionSupport == WebGLExceptionSupport.FullWithStacktrace)
                {
                    EditorGUILayout.HelpBox("'Full With Stacktrace' exception will decrease performance and increase browser memory usage. Only use this for debugging purposes, and make sure to test in a 64-bit browser.", MessageType.Warning);
                }
                if (GUI.changed)
                {
                    PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport;
                }
                GUI.changed            = false;
                WebGLCompressionFormat = (WebGLCompressionFormat)EditorGUILayout.EnumPopup("Compression Format*", PlayerSettings.WebGL.compressionFormat);
                if (GUI.changed)
                {
                    PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat;
                }
                GUI.changed      = false;
                WebGLDataCaching = EditorGUILayout.Toggle("Data caching*", WebGLDataCaching);
                if (GUI.changed)
                {
                    PlayerSettings.WebGL.dataCaching = WebGLDataCaching;
                }
                GUI.changed       = false;
                WebGLDebugSymbols = EditorGUILayout.Toggle("Debug Symbols*", WebGLDebugSymbols);
                if (GUI.changed)
                {
                    PlayerSettings.WebGL.debugSymbols = WebGLDebugSymbols;
                }

                EditorGUILayout.Space();
                GUILayout.Label("Permissions", EditorStyles.boldLabel, new GUILayoutOption[0]);
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, EditorStyles.helpBox, GUILayout.MinHeight(110f));
                if (BuildSettings.Get.permissions.Length != (int)Permissions.Count)
                {
                    System.Array.Resize(ref BuildSettings.Get.permissions, (int)Permissions.Count);
                }
                for (int i = 0; i < BuildSettings.Get.permissions.Length; i++)
                {
                    BuildSettings.Get.permissions[i] = EditorGUILayout.ToggleLeft(((Permissions)i).Name(), BuildSettings.Get.permissions[i]);
                }
                EditorGUILayout.EndScrollView();
                EditorGUILayout.Space();
                GUILayout.Label("Extra Permissions", EditorStyles.boldLabel, new GUILayoutOption[0]);
                GUILayout.Label("(one per line)");
                BuildSettings.Get.permissionsExtra = EditorGUILayout.TextArea(BuildSettings.Get.permissionsExtra, GUILayout.MinHeight(50));
                EditorGUILayout.Space();
                GUILayout.Label("Packing", EditorStyles.boldLabel, new GUILayoutOption[0]);
                BuildSettings.Get.packExtension   = EditorGUILayout.BeginToggleGroup("Pack Extension", BuildSettings.Get.packExtension);
                BuildSettings.Get.updateExtension = EditorGUILayout.BeginToggleGroup("Update", BuildSettings.Get.updateExtension);
                GUI.enabled = BuildSettings.Get.updateExtension;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(".pem file : " + Path.GetFileName(BuildSettings.Get.pemFile));
                if (GUILayout.Button("Browse..."))
                {
                    string ret = EditorUtility.OpenFilePanel("Select you .pem file", EditorUserBuildSettings.GetBuildLocation(BuildTarget.WebGL), "pem");
                    if (!string.IsNullOrEmpty(ret) && File.Exists(ret))
                    {
                        BuildSettings.Get.pemFile = ret;
                    }
                    if (!File.Exists(BuildSettings.Get.pemFile))
                    {
                        BuildSettings.Get.pemFile = "";
                    }
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndToggleGroup();
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Pack Extension..."))
                {
                    string path = EditorUtility.OpenFolderPanel("Select App Folder", EditorUserBuildSettings.GetBuildLocation(BuildTarget.WebGL), "");
                    if (Directory.Exists(path))
                    {
                        ProgressHelper progress = new ProgressHelper();
                        progress.Reset(1);
                        progress.Step("Building Player - Chrome App", "Packing Extension into .crx file");
                        if (BuildSettings.Get.packExtension)
                        {
                            if (ChromeHelper.PackExtension(path))
                            {
                                EditorUtility.RevealInFinder(path);
                            }
                        }
                        progress.Done();
                    }
                }
                GUILayout.Space(10);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndToggleGroup();
                ShowSharedNote();
            }
            EndSettingsBox();
        }