Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Unity WebGL build + Angular integration

Discussion in 'WebGL' started by Red_Dragon69, Aug 6, 2019.

  1. Red_Dragon69

    Red_Dragon69

    Joined:
    Sep 7, 2015
    Posts:
    65
    Hi all,
    is there an easy way to integrate a Unity WebGL build into an Angular 8 project, besides the following already existing solution? -> https://github.com/rgoddat/AngularUnity

    Not that this solution would be too complicated, it's just that I want to integrate my Unity build without having to rely on a third party library. Is this possible? Has anybody already tried that or some recommendations how I can tackle this?

    Best regards :)
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    489
    If you just want a unity instance in a component, that should be easy enough. Just make an angular component and in ngOnInit(), run UnityLoader.instantiate(). You will need to import the UnityLoader.js file in your template.
     
  3. Red_Dragon69

    Red_Dragon69

    Joined:
    Sep 7, 2015
    Posts:
    65
    Unfortunately this doesn't work as simple as it may sound. I added the build folder to my project, linked everything in my angular.json and index.html head. But 'UnityLoader.js' and 'UnityProgress.js' are blocked due to a MIME-Typ-Conflict ("text/html")

    If I remove the scripts from the header and try it again the webconsole shows: ERROR SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data" onload UnityLoader.js:4
     
  4. fourfourtwo

    fourfourtwo

    Joined:
    Aug 21, 2018
    Posts:
    2