Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity WebGL build + Angular integration

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

  1. Red_Dragon69

    Red_Dragon69

    Joined:
    Sep 7, 2015
    Posts:
    95
    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 :)
     
    alexxxweee likes this.
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    689
    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:
    95
    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
    alexxxweee likes this.
  5. alexxxweee

    alexxxweee

    Joined:
    Mar 2, 2020
    Posts:
    3
  6. Sakshi_09

    Sakshi_09

    Joined:
    Jul 3, 2020
    Posts:
    8
    Hi all,
    i am working on webgl and angular project. i have created a 3d scene having tv screen and i want to play live video while i am integrating my project with angular on web and that video i cannot pass in url form that is only on angular video tag and i want that video should play inside unity scene not outside.
    is this possible?
    Please help me to find the solution.

    Thanks