npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-unity

v22.1.0

Published

Angular library for embedding and communicating with Unity WebGL/WebGPU builds

Readme

ngx-unity

Angular library for embedding and communicating with Unity WebGL/WebGPU builds.

Part of the Unity-Angular-Bridge project, which also provides Unity C# code generators for type-safe bidirectional communication (typed method wrappers, signals, JSON DTOs, callbacks).

Installation

npm install ngx-unity

Requires Angular 22+.

Quick start

import { Component } from '@angular/core';
import { NgxUnityViewport, type IUnityInstance } from 'ngx-unity';

@Component({
  imports: [NgxUnityViewport],
  template: `
    <ngx-unity-viewport
      buildPath="unity"
      height="500px"
      (instanceReady)="onUnityReady($event)" />
  `,
})
export class MyComponent {
  onUnityReady(instance: IUnityInstance): void {
    instance.SendMessage('SceneManager', 'LoadObject', 'Cube-001');
  }
}

Place your Unity WebGL/WebGPU build under public/<buildPath>/ (so the loader is at public/unity/Build/unity.loader.js for buildPath="unity"). .br and .gz compressed builds are detected automatically. If no build is found, the viewport falls back to a mock instance so the rest of your app keeps working during development.

<ngx-unity-viewport>

| Input | Type | Default | Description | |---|---|---|---| | buildPath | string | 'unity' | Path to the Unity build folder (relative to public/) | | height | string | '400px' | CSS height of the canvas | | canvasId | string | auto-generated | DOM id for the canvas (identifies the instance for multi-instance routing) | | mockFactory | () => IUnityInstance | built-in mock | Custom mock factory for development | | fallbackToMock | boolean | true | Fall back to a mock when a real build fails to load; false surfaces the failure |

| Output | Type | Description | |---|---|---| | instanceReady | IUnityInstance | Emitted when Unity (or mock) is ready | | instanceCreated | { instance, canvasId } | Like instanceReady, plus the canvas id | | loadError | Error | Emitted when a build was found but failed to load |

Exposed signals: isLoading, isLoaded, useMock, loadFailed, loadingProgress, renderingBackend, resolvedCanvasId.

Multiple viewports can coexist on one page; the Unity loader script is shared per buildPath, and each canvas gets a unique DOM id.

Testing utilities

createMockUnityInstance() creates a mock IUnityInstance — useful both as the viewport's development fallback and in unit tests:

import { createMockUnityInstance } from 'ngx-unity';

const mock = createMockUnityInstance({
  onSendMessage: (gameObjectName, methodName, data) => {
    // Simulate Unity responses, e.g. invoke the window callbacks your
    // generated service listens to:
    if (methodName === 'LoadObject') {
      (window as any)['sendSelectedObjectFromUnity']?.(data);
    }
  },
});

MockUnityOptions is exported for typing custom factories.

Unity side

Type-safe bridge code (unity-client.ts, unity-jslib-exported.service.ts, and the .jslib plugin) is generated from C# attributes by the Unity editor scripts in the main repository — see its README for the full setup, JSON payload support, callbacks, and multi-instance routing.

Building & publishing (maintainers)

ng build ngx-unity
cd dist/ngx-unity
npm publish

License

GPL-3.0 — see LICENSE.