Posted in

Unity WebGL – An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was: SyntaxError: missing ; before statement

Jeżeli w Unity publikujecie grę/aplikacje w szczególności na IIS, a więc np. w Microsoft Azure może wystąpić powyższy błąd. Związane jest to z domyślną konfiguracją Microsoft Azure i sposobem serwowania wybranych plików z rozszerzeniami przez serwer. Aby gra/aplikacja działała prawidłowo w podkatalogu, w którym umieszczamy wygenerowane pliki z Unity dodajemy plik web.config z następującymi parametrami. If you use Unity to publish game or application especially using IIS, so for an example in Microsoft Azure this error may occur. This is due to the default Microsoft Azure or IIS configuration and the way of serving selected files with extensions by the server. To fix this issue please create file web.config in a subdirectory where game / application is placed with the following parameters.
web.config:
<?xml version="1.0"?>
 <configuration>
 <system.webServer>
 <staticContent>
 <remove fileExtension=".mem" />
 <remove fileExtension=".data" />
 <remove fileExtension=".unity3d" />
 <remove fileExtension=".jsbr" />
 <remove fileExtension=".membr" />
 <remove fileExtension=".databr" />
 <remove fileExtension=".unity3dbr" />
 <remove fileExtension=".jsgz" />
 <remove fileExtension=".memgz" />
 <remove fileExtension=".datagz" />
 <remove fileExtension=".unity3dgz" />
 <remove fileExtension=".json" />
 <remove fileExtension=".unityweb" />
 <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".unity3d" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".jsbr" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".membr" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".databr" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".unity3dbr" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".jsgz" mimeType="application/x-javascript; charset=UTF-8" />
 <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
 <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
 <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
 </staticContent>
 </system.webServer>
 </configuration>
 

Microsoft Certified Trainer, Office 365, AWS, Azure and Cloud Expert-Architect. In the IT world for over than 20 years.

Apart from the main area of Microsoft Azure expert in the field of infrastructure servers Windows Server 2003-2019, Microsoft Active Directory, Hyper-V Private Cloud, IIS, System Center, SQL.

Private Cloud, System Center, Hyper-V, Open Stack Expert and all Microsoft products Expert. Linux Server administrator.

My Azure community projects:

https://mazeball.azurewebsites.net/
https://github.com/MariuszFerdyn?tab=repositories

More