
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
unity-webgl
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Unity WebGL provides an easy solution for embedding Unity WebGL builds in your webApp, with two-way communication between your webApp and Unity application with advanced API's.
base on react-unity-webgl
npm install unity-webgl
<canvas id="canvas" style="width: 100%; height: 100%"></canvas>
<button onclick="onDestroy()">Destroy</button>
<button onclick="onLoad()">Reload</button>
<button onclick="onFullscreen()">Fullscreen</button>
<script>
var Unity = new UnityWebgl.default('#canvas', {
loaderUrl: 'Build/OUT_BIM.loader.js',
dataUrl: "Build/OUT_BIM.data",
frameworkUrl: "Build/OUT_BIM.framework.js",
codeUrl: "Build/OUT_BIM.wasm",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "BIM",
productVersion: "0.1",
})
Unity
.on('progress', percent => console.log('Unity progress: ', percent))
.on('loaded', percent => console.log('Unity loaded: success'))
.on('created', percent => console.log('Unity created: success'))
function postMessage() {
Unity.send('objectName', 'methodName', {
id: 'B0001',
name: 'Building#1',
location: [150, 75]
})
}
function onDestroy() {
Unity.destroy()
}
function onLoad() {
Unity.create('#canvas')
}
function onFullscreen() {
Unity.setFullscreen(true)
}
</script>
You can also:
var Unity = new UnityWebgl.default({
loaderUrl: 'Build/OUT_BIM.loader.js',
dataUrl: "Build/OUT_BIM.data",
frameworkUrl: "Build/OUT_BIM.framework.js",
codeUrl: "Build/OUT_BIM.wasm",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "BIM",
productVersion: "0.1",
})
Unity.create(document.querySelector('#canvas'))
events:
on(eventName: string, eventListener: function)
once(eventName: string, eventListener: function)
off(eventName: string)
clear()
dispatch(eventName: string)
instance:
create(canvasElement: HTMLCanvasElement | string)
send(objectName: string, methodName: string, params: any)
setFullscreen()
destroy()
FAQs
Unity-WebGL provides an easy solution for embedding Unity WebGL builds in your web projects, with two-way communication between your webApp and Unity application with advanced API's.
The npm package unity-webgl receives a total of 1,048 weekly downloads. As such, unity-webgl popularity was classified as popular.
We found that unity-webgl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.