Exemplo n.º 1
0
 public static void OnPostProcessBuild(BuildTarget target, string targetPath)
 {
     if (target == BuildTarget.WebGL)
     {
         settings = BuildPipelineWebGLSettings.Instance;
         if (settings.stripMobileWarning)
         {
             try
             {
                 var path = Path.Combine(targetPath, "Build/UnityLoader.js");
                 var sb   = new StringBuilder(File.ReadAllText(path));
                 sb = sb.Replace("UnityLoader.SystemInfo.mobile", "false");
                 File.WriteAllText(path, sb.ToString());
             }
             catch (Exception e)
             {
                 UnityEngine.Debug.LogException(e);
             }
         }
         if (settings.fixMacOSVersionRegex)
         {
             try
             {
                 var path = Path.Combine(targetPath, "Build/UnityLoader.js");
                 var sb   = new StringBuilder(File.ReadAllText(path));
                 sb = sb.Replace("Mac OS X (10[\\.\\_\\d]+)", "Mac OS X (1[0-9][\\.\\_\\d]+)");
                 File.WriteAllText(path, sb.ToString());
             }
             catch (Exception e)
             {
                 UnityEngine.Debug.LogException(e);
             }
         }
     }
 }
Exemplo n.º 2
0
 public static void OnPostProcessBuild(BuildTarget target, string targetPath)
 {
     settings = BuildPipelineWebGLSettings.Instance;
     if (settings.stripMobileWarning && target == BuildTarget.WebGL)
     {
         try
         {
             var path = Path.Combine(targetPath, "Build/UnityLoader.js");
             var text = File.ReadAllText(path);
             text = text.Replace("UnityLoader.SystemInfo.mobile", "false");
             File.WriteAllText(path, text);
         }
         catch (Exception e)
         {
             UnityEngine.Debug.LogException(e);
         }
     }
 }
 private void OnEnable()
 {
     settings = BuildPipelineWebGLSettings.Instance;
 }
Exemplo n.º 4
0
        public static void Build()
        {
            if (UnityEditor.BuildPipeline.isBuildingPlayer)
            {
                return;
            }
            settings = BuildPipelineWebGLSettings.Instance;
            string path;

            if (string.IsNullOrEmpty(settings.buildPath))
            {
                path = OpenBuildSavePanel(settings.buildPath);
            }
            else
            {
                path = settings.buildPath;
            }
            var scenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

            for (int i = 0; i < scenes.Count; i++)
            {
                if (!scenes[i].enabled)
                {
                    scenes.RemoveAt(i--);
                }
            }
            if (!(scenes.Count > 0))
            {
                return;
            }
            string buildPath;

            if (settings.createNewFolder)
            {
                buildPath = Path.Combine(path, settings.GetFolderName());
            }
            else
            {
                buildPath = path;
            }
            PlayerSettings.WebGL.linkerTarget      = settings.linkerTarget;
            PlayerSettings.WebGL.memorySize        = settings.memorySize;
            PlayerSettings.WebGL.compressionFormat = settings.compressionFormat;
            PlayerSettings.WebGL.wasmStreaming     = settings.wasmStreaming;
            BuildReport  report  = UnityEditor.BuildPipeline.BuildPlayer(scenes.ToArray(), buildPath, BuildTarget.WebGL, settings.buildOptions);
            BuildSummary summary = report.summary;

            if (summary.result == BuildResult.Succeeded)
            {
                Debug.Log($"Build succeeded at '{buildPath}' using {summary.totalTime.TotalSeconds.ToString("N2")} seconds with size of {summary.totalSize} bytes.");
#if UNITY_EDITOR_OSX
                Application.OpenURL("file:/" + buildPath);
#else
                Application.OpenURL(buildPath);
#endif
            }
            if (summary.result == BuildResult.Failed)
            {
                Debug.LogError($"Build failed...");
            }
        }