Angular Unity by kmturley - 1

Games & ProjectsSDK

Example Angular and Unity integration

Unknown VersionUnknown LicenseUpdated 22 days agoCreated on October 18th, 2018
Go to source


Example Angular and Unity integration using:

  • Unity 2019.3.14f1
  • Angular 12.0.x


npm install


npm start

Then view the site at:


Creating a compatible Unity project

To communicate between JavaScript and Unity you need a few things:

  1. Create a Unity Project with GameObject > Controller.cs:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System.Runtime.InteropServices;

    public class Controller : MonoBehaviour {

        private static extern void SendMessageToWeb(string msg);

        public void ReceiveMessageFromWeb(string msg) {
            Debug.Log("Controller.ReceiveMessageFromWeb: " + msg);

        // Use this for initialization
        void Start() {
            SendMessageToWeb("Hello from Unity");

        // Update is called once per frame
        void Update() {

  1. Add a file to the Unity project at: /Assets/Plugins/WebInterface.jslib containing:
    mergeInto(LibraryManager.library, {
    SendMessageToWeb: function (str) {
  1. Build the project as WebGL so that it creates the files:
  • demo.json
  • demo.wasm.code.unityweb
  • demo.wasm.framework.unityweb
  1. Copy the generated files to this project folder:


  2. Embed your generated files using the reusable Angular component:

Updating Unity

If you update Unity then you’ll also needs to update the Unity JavaScript files to match. Publish a WebGL project and copy the new JavaScript files into the angular src folder here:


Directory structure

src/                       --> Frontend sources files
unity-src/                 --> Unity script examples


For more information please contact kmturley

Show all projects by kmturley