Agent skill
daniel-unity
Unity 6 WebGL/WebGPU development with React integration. Use when building, optimizing, or debugging Unity Web builds.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/daniel-unity
SKILL.md
Unity 6 WebGL & WebGPU Development
When to Use
Activate this skill when:
- Building Unity WebGL/WebGPU projects
- Integrating Unity with React (react-unity-webgl)
- Optimizing Unity Web builds (memory, size, performance)
- Debugging Unity WebGL issues
- Setting up JavaScript ↔ Unity communication
- Configuring server deployment for Unity builds
- Working with compute shaders or WebGPU features
Reference Documentation
Primary Reference: docs/unity-6-webgl-webgpu-reference.md
Read this file for comprehensive coverage of:
- WebGL vs WebGPU comparison
- Build settings & optimization
- Memory management (GC constraints, NativeArray patterns)
- JavaScript interop (JSLib, SendMessage, DllImport)
- React Unity WebGL integration
- Audio, input, networking limitations
- Browser compatibility
- Deployment configuration
- Common issues & solutions
Quick Reference
WebGPU Enable Steps
- Edit → Project Settings → Player → Web
- Other Settings → disable Auto Graphics API
- Add WebGPU, drag to top
- Keep WebGL2 as fallback
React → Unity Communication
const { sendMessage } = useUnityContext({
/* config */
});
sendMessage('GameObjectName', 'MethodName', parameter);
Unity → React Communication
JSLib: Assets/Plugins/WebGL/Bridge.jslib
mergeInto(LibraryManager.library, {
SendToReact: function (dataPtr) {
var data = UTF8ToString(dataPtr);
window.dispatchReactUnityEvent('EventName', data);
},
});
C#:
[DllImport("__Internal")]
private static extern void SendToReact(string data);
#if UNITY_WEBGL && !UNITY_EDITOR
SendToReact(jsonData);
#endif
Memory Optimization
// Use NativeArray to bypass GC
using (var data = new NativeArray<byte>(size, Allocator.Temp)) {
// Operations
} // Disposed immediately
// Never do this - quadratic memory growth
string result = "";
for (int i = 0; i < 10000; i++) {
result += i.ToString(); // BAD - GC can't run mid-loop
}
Build Settings Checklist
- Brotli compression (HTTPS)
- Code stripping: High
- Strip Engine Code: enabled
- Exception support: None (release)
- Name Files As Hashes: enabled
- Data Caching: enabled
Server Headers (Brotli)
Content-Encoding: br
Content-Type: application/wasm (for .wasm.br)
Key Limitations to Remember
| Feature | WebGL2 | WebGPU |
|---|---|---|
| Compute Shaders | No | Yes |
| VFX Graph | No | Yes |
| Status | Production | Experimental |
Always:
- Require user interaction before audio
- Use coroutines (never blocking calls)
- Configure CORS headers for cross-origin requests
- Test on multiple browsers
Never:
- Use synchronous GPU readback (WebGPU)
- Use RWBuffer in compute shaders (use RWStructuredBuffer)
- Block on WWW/WebRequest downloads
- Use System.Net classes
File Locations
| Purpose | Location |
|---|---|
| JSLib plugins | Assets/Plugins/WebGL/*.jslib |
| Pre-execution JS | Assets/Plugins/WebGL/*.jspre |
| Web templates | Assets/WebGLTemplates/ |
| Build output | Build/ folder |
| Reference doc | docs/unity-6-webgl-webgpu-reference.md |
Common Issues Quick Fix
| Issue | Solution |
|---|---|
| Out of memory | Reduce heap size, use AssetBundles |
| CORS error | Add Access-Control headers on server |
| Audio not playing | Require user click/tap first |
| Code stripping broke something | Add to link.xml |
| Incorrect header check | Configure server compression headers |
Related Skills
theone-unity-standards- C# coding patternsfrontend-development- React/TypeScript patternsbackend-development- Server configuration
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?