Skip to content

Instantly share code, notes, and snippets.

@RimuruDev
Forked from JohannesDeml/README.md
Created June 6, 2023 19:12
Show Gist options
  • Select an option

  • Save RimuruDev/54be1aea9b905b1831a9fcf8693219cc to your computer and use it in GitHub Desktop.

Select an option

Save RimuruDev/54be1aea9b905b1831a9fcf8693219cc to your computer and use it in GitHub Desktop.

Revisions

  1. @JohannesDeml JohannesDeml revised this gist Apr 26, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions RemoveMobileSupportWarningWebBuild.cs
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@
    // </author>
    // --------------------------------------------------------------------------------------------------------------------

    #if !UNITY_2020_1_OR_NEWER //Not needed anymore in 2020 and above
    using System.IO;
    using UnityEditor;
    using UnityEditor.Callbacks;
    @@ -21,7 +22,6 @@ namespace Supyrb
    /// </summary>
    public class RemoveMobileSupportWarningWebBuild
    {
    #if !UNITY_2020_1_OR_NEWER //Not needed anymore in 2020 and above
    [PostProcessBuild]
    public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    {
    @@ -44,6 +44,6 @@ public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    File.WriteAllText(filePath, text);
    }
    }
    #endif
    }
    }
    }
    #endif
  2. @JohannesDeml JohannesDeml revised this gist Apr 26, 2021. 2 changed files with 7 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Remove warning
    Unity has a warning when running a webgl build on mobile (iOS, Android). In order to remove it, just add this file to an editor folder.
    Unity shows the following warning on mobile devices up to Unity 2019.4: "Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway." This script helps you remove this warning

    ## Live example
    To see live examples see [Unity Web GL Loading Test](https://github.com/JohannesDeml/UnityWebGL-LoadingTest)
    6 changes: 6 additions & 0 deletions RemoveMobileSupportWarningWebBuild.cs
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,13 @@

    namespace Supyrb
    {
    /// <summary>
    /// removes a warning popup for mobile builds, that this platform might not be supported:
    /// "Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway."
    /// </summary>
    public class RemoveMobileSupportWarningWebBuild
    {
    #if !UNITY_2020_1_OR_NEWER //Not needed anymore in 2020 and above
    [PostProcessBuild]
    public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    {
    @@ -39,5 +44,6 @@ public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    File.WriteAllText(filePath, text);
    }
    }
    #endif
    }
    }
  3. @JohannesDeml JohannesDeml revised this gist Apr 23, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,12 @@ The script will run after the build has completed and replace the checks from al
    ## Trouble Shooting
    If you still see the message, there are several reasons why this could happen
    * Make sure you included the file in an **Editor** folder inside your project (e.g. `Assets/Editor/RemoveMobileSupportWarningWebBuild.cs`)
    * Make sure you get a console log message "Removing mobile warning from YOURPATH" after the build is finished. If you don't get this message there is a problem with your integration of the script. Probably, the script is not in the Editor folder.
    * Make sure you emptied your browser cache on the device you are testing on ([Android](https://support.google.com/accounts/answer/32050) | [iOS](https://support.apple.com/en-us/HT201265))
    * Try to open the website in private mode, might help with strage cache problems
    * Take a look at [Unity Web GL Loading Test](https://github.com/JohannesDeml/UnityWebGL-LoadingTest). There you can see the script in action, take a look at how the script is integrated or build the repo yourself to see how it should behave.
    * Inside you Build folder, take a look at the `*.js` file, and see if you can find an instance of "UnityLoader.SystemInfo.mobile". If you can still find that, the script didn't run properly.
    * If you need professional help, you can write me an [email](mailto:[email protected])

    ## Further Notes
    * Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
  4. @JohannesDeml JohannesDeml revised this gist Apr 23, 2021. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ The script will run after the build has completed and replace the checks from al
    ## Trouble Shooting
    If you still see the message, there are several reasons why this could happen
    * Make sure you included the file in an **Editor** folder inside your project (e.g. `Assets/Editor/RemoveMobileSupportWarningWebBuild.cs`)
    * Make sure you emptied your browser cache on the device you are testing on ([Android](https://support.google.com/accounts/answer/32050)[iOS] | (https://support.apple.com/en-us/HT201265))
    * Make sure you emptied your browser cache on the device you are testing on ([Android](https://support.google.com/accounts/answer/32050) | [iOS](https://support.apple.com/en-us/HT201265))
    * Try to open the website in private mode, might help with strage cache problems

    ## Further Notes
    2 changes: 1 addition & 1 deletion RemoveMobileSupportWarningWebBuild.cs
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    var text = File.ReadAllText(filePath);
    text = text.Replace("UnityLoader.SystemInfo.mobile", "false");

    Debug.Log("Removing iOS warning from " + filePath);
    Debug.Log("Removing mobile warning from " + filePath);
    File.WriteAllText(filePath, text);
    }
    }
  5. @JohannesDeml JohannesDeml revised this gist Apr 22, 2021. 2 changed files with 10 additions and 5 deletions.
    11 changes: 8 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,15 @@ To see live examples see [Unity Web GL Loading Test](https://github.com/Johannes
    The script will run after the build has completed and replace the checks from all generated javascript files.

    ## Support
    * Tested with Unity 2019.3, but should work with any version
    * Tested up to Unity 2020.3, but should work with any version
    * Works with `Name Files as Hashes`, since it looks for all js files in the Build folder
    * Only runs when building for WebGL, so you can use it for a multiplatform project

    ## Trouble Shooting
    If you still see the message, there are several reasons why this could happen
    * Make sure you included the file in an **Editor** folder inside your project (e.g. `Assets/Editor/RemoveMobileSupportWarningWebBuild.cs`)
    * Make sure you emptied your browser cache on the device you are testing on ([Android](https://support.google.com/accounts/answer/32050)[iOS] | (https://support.apple.com/en-us/HT201265))
    * Try to open the website in private mode, might help with strage cache problems

    ## Further Notes
    * Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
    * You might need to empty your browser cache to get the new javascript file without any warnings
    * Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
    4 changes: 2 additions & 2 deletions RemoveMobileSupportWarningWebBuild.cs
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // --------------------------------------------------------------------------------------------------------------------
    // <copyright file="RemoveMobileSupportWarningWebBuild.cs" company="Supyrb">
    // Copyright (c) 2020 Supyrb. All rights reserved.
    // <copyright file="RemoveMobileSupportWarningWebBuild.cs">
    // Copyright (c) 2021 Johannes Deml. All rights reserved.
    // </copyright>
    // <author>
    // Johannes Deml
  6. @JohannesDeml JohannesDeml revised this gist Dec 25, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    # Remove warning
    Unity has a warning when running a webgl build on mobile (iOS, Android). In order to remove it, just add this file to an editor folder.

    ## Live example
    To see live examples see [Unity Web GL Loading Test](https://github.com/JohannesDeml/UnityWebGL-LoadingTest)

    ## Logic
    The script will run after the build has completed and replace the checks from all generated javascript files.

  7. @JohannesDeml JohannesDeml revised this gist Mar 3, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,5 @@ The script will run after the build has completed and replace the checks from al
    * Only runs when building for WebGL, so you can use it for a multiplatform project

    ## Further Notes
    Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
    * Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
    * You might need to empty your browser cache to get the new javascript file without any warnings
  8. @JohannesDeml JohannesDeml created this gist Feb 14, 2020.
    13 changes: 13 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # Remove warning
    Unity has a warning when running a webgl build on mobile (iOS, Android). In order to remove it, just add this file to an editor folder.

    ## Logic
    The script will run after the build has completed and replace the checks from all generated javascript files.

    ## Support
    * Tested with Unity 2019.3, but should work with any version
    * Works with `Name Files as Hashes`, since it looks for all js files in the Build folder
    * Only runs when building for WebGL, so you can use it for a multiplatform project

    ## Further Notes
    Unity adds this note, since the builds oftentimes don't work for mobile, so oftentimes it does make sense to include the info.
    43 changes: 43 additions & 0 deletions RemoveMobileSupportWarningWebBuild.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    // --------------------------------------------------------------------------------------------------------------------
    // <copyright file="RemoveMobileSupportWarningWebBuild.cs" company="Supyrb">
    // Copyright (c) 2020 Supyrb. All rights reserved.
    // </copyright>
    // <author>
    // Johannes Deml
    // [email protected]
    // </author>
    // --------------------------------------------------------------------------------------------------------------------

    using System.IO;
    using UnityEditor;
    using UnityEditor.Callbacks;
    using UnityEngine;

    namespace Supyrb
    {
    public class RemoveMobileSupportWarningWebBuild
    {
    [PostProcessBuild]
    public static void OnPostProcessBuild(BuildTarget target, string targetPath)
    {
    if (target != BuildTarget.WebGL)
    {
    return;
    }

    var buildFolderPath = Path.Combine(targetPath, "Build");
    var info = new DirectoryInfo(buildFolderPath);
    var files = info.GetFiles("*.js");
    for (int i = 0; i < files.Length; i++)
    {
    var file = files[i];
    var filePath = file.FullName;
    var text = File.ReadAllText(filePath);
    text = text.Replace("UnityLoader.SystemInfo.mobile", "false");

    Debug.Log("Removing iOS warning from " + filePath);
    File.WriteAllText(filePath, text);
    }
    }
    }
    }