Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
6
Question by JPSMProductions · Apr 11, 2017 at 05:37 PM · androidunity 5iosmobilewebgl

Unity WebGL Disable mobile warning

Hi,

I would like to disable the default warning: "Please note that Unity WebGL is not currently supported on mobiles."

Does anyone know if it's possible?

In the Unity Forums the user "jonas-echterhoff" wrote that you could deactivate the message. https://forum.unity3d.com/threads/webgl-for-mobile-devices.291068/#post-1921583

Thanks and have a nice day, Jordan Kniest

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

12 Replies

· Add your reply
  • Sort: 
avatar image
13

Answer by Skylabs · Oct 11, 2018 at 01:44 PM

Hi here is a new version that is working with the 2018 version :-)

 using System;
     using System.IO;
     using System.Text.RegularExpressions;
     using UnityEditor;
     using UnityEditor.Callbacks;
     
     public class PostBuildActions
     {
         [PostProcessBuild]
         public static void OnPostProcessBuild(BuildTarget target, string targetPath)
         {
             var path = Path.Combine(targetPath, "Build/UnityLoader.js");
             var text = File.ReadAllText(path);
             text = text.Replace("UnityLoader.SystemInfo.mobile", "false");
             File.WriteAllText(path, text);
         }
     }
 
 
Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dfarjoun · Oct 27, 2018 at 07:13 PM 0
Share

I'm using the 2018 version and just saw this message (newbie). What should I do with this code?

avatar image Skylabs · Oct 28, 2018 at 06:58 PM 1
Share

@kleber-swf explained it good in his post :

Just create a file PostBuildActions.cs inside any Editor folder and execute your build normally. It will replace the problematic function with the proposed solution.

So create the file PostBuildActions and post the above code inside and normally when you will build your Webgl, no more mobile warning ! Right like that ? :-)

avatar image kleber-swf · Oct 29, 2018 at 11:15 AM 0
Share

And if some of the questions helped you, help the community back and give them an up vote. This will make the life of the next people who look for the same answer easier. Cheers!

avatar image janoonk · Jun 03, 2019 at 02:33 PM 0
Share

In Unity 2019.3.0a3 when WebGL Building I get an error: The type or namespace name 'Callbacks' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

avatar image Patomanriquezb · Jun 13, 2019 at 09:49 PM 1
Share

For Unity 2019 replace: [PostProcessBuild]

with: [PostProcessBuildAttribute(1)]

It works for me, I'm in v2019.3.0a3.

Cheers!

avatar image janoonk Patomanriquezb · Jun 14, 2019 at 11:56 AM 0
Share

I tried that but I get the same error when building for WebGL.This is my PostProcessBuildScript.cs

 using UnityEngine;
 using UnityEditor;
 using UnityEditor.Callbacks;
 
 public class PostProcessBuildScript
 {
     [PostProcessBuildAttribute(1)]
     public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
     {
         Debug.Log("Called from OnPostprocessBuild: "+pathToBuiltProject);
     }
 }

avatar image Patomanriquezb janoonk · Jun 14, 2019 at 02:55 PM 3
Share

I think I know what's the problem. This particular script needs to be inside a folder named Editor, it can be anywhere in your project, but it has to have that name. The thing is, this script is not supposed to be built into your WebGL app, it only modifies the building process, so you HAVE to put it in that folder so Unity can know that.

Show more comments
avatar image amitkumbhar14 Patomanriquezb · May 21, 2020 at 12:45 PM 0
Share

Where can i get PostProcessBuildAttribute script ? Thanks

avatar image
7

Answer by kart_ranger · Sep 24, 2017 at 01:00 AM

To understand what exactly goes with the js script, format it first, mine was completely not formatted. I used this jsbeautifier.org. Anyways, all you have to do is the following to by pass the warning. For your clarity i'm attaching my UnityLoader.js as well.

 compatibilityCheck: function(e, t, r) {
         t();
     },



[1]: /storage/temp/102465-unityloader.zip


unityloader.zip (87.9 kB)
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dadc · Oct 08, 2017 at 07:34 AM 0
Share

Worked for me - thanks.

avatar image slotoe · Jan 25, 2020 at 04:23 PM 0
Share

Can confirm, this works for 2019 version of Unity aswell. Thank you!

avatar image
3

Answer by kleber-swf · Mar 09, 2018 at 09:45 PM

Based on @kart_ranger 's answer, I made a small class to handle it automatically after the build is done:

 using System;
 using System.IO;
 using System.Text.RegularExpressions;
 using UnityEditor;
 using UnityEditor.Callbacks;
 
 public class PostBuildActions {
     [PostProcessBuild]
     public static void OnPostProcessBuild(BuildTarget target, string targetPath) {
         var path = Path.Combine(targetPath, "Build/UnityLoader.js");
         var text = File.ReadAllText(path);
         text = Regex.Replace(text, @"compatibilityCheck:function\(e,t,r\)\{.+,Blobs:\{\},loadCode",
             "compatibilityCheck:function(e,t,r){t()},Blobs:{},loadCode");
         File.WriteAllText(path, text);
     }
 }

Just create a file PostBuildActions.cs inside any Editor folder and execute your build normally. It will replace the problematic function with the proposed solution.

Please keep in mind that this code could be incompatible with future versions of Unity WebGL build. It was tested on Unity Editor 2017.3.0f3

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Schubkraft · Apr 13, 2017 at 08:07 AM

The message is part of the UnityLoader.js file and you can just edit that to whatever you want with a text editor.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JPSMProductions · Apr 13, 2017 at 01:38 PM 0
Share

Thanks.. I can now skip the message :)

avatar image ina · May 23, 2018 at 11:36 AM 0
Share

It seems UnityLoader.js is generated each time - is there a way to have this mod be persistent?

avatar image Schubkraft ♦♦ · May 23, 2018 at 11:43 AM 0
Share

See below for the PostProcess version or edit the original files under where Unity gets them for the builds.

avatar image
2

Answer by nullgamestudio · Nov 26, 2019 at 08:42 PM

Hello everyone, this works for me in 2019.2.4 :

 UnityLoader.compatibilityCheck=function(e,t,r){t();};


in the index.html file , right before the unityloader instantiate line.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image el-beto-acosta · Jul 01, 2020 at 05:39 AM 0
Share

Thank you so mucho!!! Work for me in Unity 2017.2.1f1

Thank you again.

avatar image STALKER-LIVE · Nov 07, 2020 at 10:02 AM 0
Share

у меня тоже это работает в 2019.4

avatar image P3TCHZ · Nov 20, 2020 at 04:27 AM 0
Share

still working in unity 2019.2.3f1

  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to publish 400mb size apk to playstore exported from unity in android studio? 0 Answers

Shadows problem on mobile device 0 Answers

how to make Unity Remote settings backend 1 Answer

Problem when build terrain on android device 0 Answers

Namespace Gamecenter not found on Unity 2017.2 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges