Skip to content

Instantly share code, notes, and snippets.

@caphosra
Created June 24, 2020 02:33
Show Gist options
  • Save caphosra/887786a1d6aeaf070237579b95d64d4b to your computer and use it in GitHub Desktop.
Save caphosra/887786a1d6aeaf070237579b95d64d4b to your computer and use it in GitHub Desktop.
Detele mobile warning dialog from Unity WebGL build
import pathlib
delete_func = "compatibilityCheck:function(e,t,r){UnityLoader.SystemInfo.hasWebGL?UnityLoader.SystemInfo.mobile?e.popup(\"Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway.\",[{text:\"OK\",callback:t}]):[\"Edge\",\"Firefox\",\"Chrome\",\"Safari\"].indexOf(UnityLoader.SystemInfo.browser)==-1?e.popup(\"Please note that your browser is not currently supported for this Unity WebGL content. Press OK if you wish to continue anyway.\",[{text:\"OK\",callback:t}]):t():e.popup(\"Your browser does not support WebGL\",[{text:\"OK\",callback:r}])}"
expected_func = "compatibilityCheck:function(e,t,r){r();}"
def main():
path = input("Input the directory path of UnityLoader.js > ")
path = str(pathlib.Path(path).joinpath("UnityLoader.js"))
script = ""
with open(path, "r") as fs:
script = fs.read()
script = script.replace(delete_func, expected_func)
with open(path, "w") as fs:
fs.write(script)
if __name__ == "__main__":
main()
@caphosra
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment