// Make sure to add this to your Unity Cloud Build -> Advanced Options -> Post-Export Method -> `PostProcessWebGL.PostExport` public static void PostExport(string exportPath) { Debug.Log("PostProcessWebGL.PostExport() called."); Debug.LogFormat($" PlayerSettings.WebGL.template = '{PlayerSettings.WebGL.template}'"); Debug.LogFormat($" TemplatePath: '{TemplatePath}'"); // Clear the TemplateData folder, built by Unity. FileUtilExtended.CreateOrCleanDirectory(Paths.Combine(exportPath, "TemplateData")); // Copy contents from WebGLTemplate. Ignore all .meta files FileUtilExtended.CopyDirectoryFiltered(TemplatePath, exportPath, true, @".*/\.+|\.meta$", true); // Replace contents of index.html FixIndexHtml(exportPath); }
public static void ChangeWebGLTemplate(BuildTarget buildTarget, string pathToBuiltProject) { if (buildTarget != BuildTarget.WebGL) { return; } //create template path var templatePath = Paths.Combine(Application.dataPath, "WebGLTemplates", __TemplateToUse); //Clear the TemplateData folder, built by Unity. FileUtilExtended.CreateOrCleanDirectory(Paths.Combine(pathToBuiltProject, "TemplateData")); //Copy contents from WebGLTemplate. Ignore all .meta files FileUtilExtended.CopyDirectoryFiltered(templatePath, pathToBuiltProject, true, @".*/\.+|\.meta$", true); //Replace contents of index.html FixIndexHtml(pathToBuiltProject); }