Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
a22b0b2
Use script.remove instead of removeChild for unity loader hook (#576)
alexqhj May 15, 2025
c0c58fe
Removed deprecated actions
jeffreylanters May 19, 2025
ade588e
Add autoSyncPersistentDataPath to ConfigurableUnityArguments type
jeffreylanters Jun 16, 2025
583ef34
Update RELEASE-NOTES.md to add support for autoSyncPersistentDataPath…
jeffreylanters Jun 16, 2025
31f37bd
Bump version to 9.9.0 in package.json and package-lock.json
jeffreylanters Jun 16, 2025
9e5ca18
Update cache action to v4 in workflow files
jeffreylanters Jun 16, 2025
1de5449
Started reworking module source
jeffreylanters Jul 15, 2025
af7320d
Initial Unity component
jeffreylanters Jul 15, 2025
21255e0
Removed unused exports
jeffreylanters Jul 15, 2025
2177d85
Updated packages
jeffreylanters Jul 15, 2025
49c3acd
Fix import path for UnityInstance in global type declarations
jeffreylanters Jul 15, 2025
c18e903
Remove unused type declarations for UnityBooleanLike, UnityInstance, …
jeffreylanters Jul 15, 2025
bd191de
Refactor Unity component to use forwardRef and improve type safety
jeffreylanters Jul 15, 2025
8ca63ab
Add useCanvasIdentifier hook to generate unique Unity canvas IDs
jeffreylanters Jul 15, 2025
f17d87f
Add useUnityLoader hook to manage Unity loader status in Unity component
jeffreylanters Jul 15, 2025
c0f7428
Add isBrowserEnvironment constant to check for browser environment
jeffreylanters Jul 15, 2025
6825b4f
Add useUnityContext hook to manage Unity configuration and provider
jeffreylanters Jul 15, 2025
56689c9
Add useUnityLoader hook to manage Unity loader script and status
jeffreylanters Jul 15, 2025
02bf8d9
Add type definition for ReactUnityEventParameter to support Unity eve…
jeffreylanters Jul 15, 2025
eb2dcf3
Add UnityArguments type definition to initialize Unity instance with …
jeffreylanters Jul 15, 2025
e7053a3
Add UnityBooleanLike type declaration to represent boolean values in …
jeffreylanters Jul 15, 2025
afefba7
Add UnityCacheControlMode type definition to manage caching behavior …
jeffreylanters Jul 15, 2025
f5d711b
Add UnityConfig type definition to specify Unity configuration options
jeffreylanters Jul 15, 2025
290a947
Add type definition for UnityContext to encapsulate Unity Provider in…
jeffreylanters Jul 15, 2025
1d0066a
Add type definition for UnityInstanceBannerType to represent banner m…
jeffreylanters Jul 15, 2025
e2575ae
Add type declaration for UnityInstance to define its methods and prop…
jeffreylanters Jul 15, 2025
0acc28e
Add type definition for UnityLoaderStatus to represent loader states
jeffreylanters Jul 15, 2025
b64ca0b
Add type declaration for UnityModule to define its methods and proper…
jeffreylanters Jul 15, 2025
0b336be
Add type declaration for UnityProps to define properties for Unity co…
jeffreylanters Jul 15, 2025
71e44ac
Add type declaration for UnityProvider to define properties for Unity…
jeffreylanters Jul 15, 2025
27edd9c
Export useUnityContext from the module for improved accessibility
jeffreylanters Jul 15, 2025
6847e38
Update TypeScript and @types/react to latest versions for improved co…
jeffreylanters Jul 15, 2025
7ca4496
Add Unity WebGL loader and WebAssembly binary
jeffreylanters Jul 15, 2025
abc20db
Refactor Application component to simplify Unity integration and remo…
jeffreylanters Jul 15, 2025
957a4ca
Remove react-unity-webgl dependency from package.json and package-loc…
jeffreylanters Jul 15, 2025
fb21ed7
Enhance Unity component to support dynamic initialization and cleanup…
jeffreylanters Jul 15, 2025
ae0237e
Fix canvas ID generation to prevent incrementing canvas count prematu…
jeffreylanters Jul 15, 2025
1bee99f
Refactor event parameter types to unify Unity event handling and remo…
jeffreylanters Jul 15, 2025
b5477c9
Pass loading progression callback to createUnityInstance for enhanced…
jeffreylanters Jul 15, 2025
b4918f2
Add loading progression state to useUnityContext for enhanced loading…
jeffreylanters Jul 15, 2025
f36f6b6
Add loading progression property to UnityContext type for improved lo…
jeffreylanters Jul 15, 2025
29b8d5c
Add setLoadingProgression method to UnityProvider type for loading fe…
jeffreylanters Jul 15, 2025
6bf610d
Update Application component to display loading progression and adjus…
jeffreylanters Jul 15, 2025
b236235
Implement loading progression callback in Unity component for enhance…
jeffreylanters Jul 15, 2025
5d0237f
Add isLoaded state to useUnityContext for tracking loading completion
jeffreylanters Jul 15, 2025
8d1ae0e
Add isLoaded property to UnityContext type for loading state tracking
jeffreylanters Jul 15, 2025
54b8c12
Add optional setIsLoaded method to UnityProvider type for loading sta…
jeffreylanters Jul 15, 2025
e422dc7
Export UnityEventParameter type from exports.ts for improved type acc…
jeffreylanters Jul 15, 2025
d900502
Enhance Application component with loading state tracking and console…
jeffreylanters Jul 15, 2025
a342974
Reset loading state and handle initialization errors in Unity component
jeffreylanters Jul 15, 2025
03c40bd
Add initialisationError state management to useUnityContext hook
jeffreylanters Jul 15, 2025
f305e14
Add initialisationError property to UnityContext type for error handling
jeffreylanters Jul 15, 2025
9315e2c
Make setIsLoaded property mandatory in UnityProvider type definition
jeffreylanters Jul 15, 2025
c4d67ad
Use nullish coalescing operator for initialisationError message display
jeffreylanters Jul 15, 2025
ad574e1
Add devicePixelRatio to Unity instance creation for improved rendering
jeffreylanters Jul 15, 2025
fd4ae0d
Refactor UnityProps type to include devicePixelRatio from UnityArguments
jeffreylanters Jul 15, 2025
874ce7d
Add devicePixelRatio to canvas for improved rendering quality
jeffreylanters Jul 15, 2025
22e7a67
Enhance documentation for useUnityContext hook and Unity component er…
jeffreylanters Jul 15, 2025
8e9dfc4
Enable requestFullscreen functionality in Application component
jeffreylanters Jul 15, 2025
b287415
Refactor UnityInstance type declaration to use Pick for improved clar…
jeffreylanters Jul 16, 2025
62b22fe
Refactor UnityInstance type declaration to include Quit method for im…
jeffreylanters Jul 16, 2025
0bbdda3
Refactor UnityModule type declaration to improve structure and add mi…
jeffreylanters Jul 16, 2025
fd2a891
Remove unused imports from UnityInstance type declaration for cleaner…
jeffreylanters Jul 16, 2025
a5acf4d
Enable requestFullscreen functionality and add missing properties in …
jeffreylanters Jul 16, 2025
eb16ebd
Refactor UnityProvider type declaration to include additional propert…
jeffreylanters Jul 16, 2025
c201786
Refactor UnityConfig type declaration to include additional propertie…
jeffreylanters Jul 16, 2025
93d9491
Refactor useUnityContext to include companyName, productName, and pro…
jeffreylanters Jul 16, 2025
1f0ebf5
Add companyName, productName, and productVersion to Unity instance cr…
jeffreylanters Jul 16, 2025
27030f3
Refactor UnityProvider type declaration to include setUnityInstance m…
jeffreylanters Jul 16, 2025
0c162ba
Refactor UnityContext type declaration to include requestFullscreen m…
jeffreylanters Jul 16, 2025
511c122
Refactor useUnityContext to include requestFullscreen method for impr…
jeffreylanters Jul 16, 2025
5f8f4c2
Refactor Unity instance management to ensure proper detachment and re…
jeffreylanters Jul 16, 2025
301066c
Refactor Application component to enable requestPointerLock and sendM…
jeffreylanters Jul 16, 2025
651de5f
Refactor UnityProvider type declaration to include additional Unity a…
jeffreylanters Jul 16, 2025
ca669be
Refactor UnityContext type declaration to include requestPointerLock …
jeffreylanters Jul 16, 2025
7ab2f9a
Refactor UnityConfig type declaration to include additional Unity ass…
jeffreylanters Jul 16, 2025
8092119
Refactor useUnityContext to include additional Unity asset properties…
jeffreylanters Jul 16, 2025
de54e23
Refactor Unity component to include additional Unity asset properties…
jeffreylanters Jul 16, 2025
04ae1f3
Refactor UnityContext type declaration to include sendMessage method …
jeffreylanters Jul 16, 2025
529a36e
Add sendMessage method to useUnityContext for invoking public methods…
jeffreylanters Jul 16, 2025
f511c49
Enable takeScreenshot functionality in Application component
jeffreylanters Jul 16, 2025
c6ca53d
Add takeScreenshot method to UnityContext for capturing screenshots
jeffreylanters Jul 16, 2025
35e3107
Add takeScreenshot method to useUnityContext for capturing screenshots
jeffreylanters Jul 16, 2025
f2057f7
Refactor comments in useUnityContext and update takeScreenshot parame…
jeffreylanters Jul 16, 2025
8ead86b
Enable webglContextAttributes in Application component for preserving…
jeffreylanters Jul 16, 2025
def3cce
Add webglContextAttributes to UnityProvider type definition
jeffreylanters Jul 16, 2025
21b7da8
Add webglContextAttributes to UnityConfig type definition
jeffreylanters Jul 16, 2025
dc58bd7
Add webglContextAttributes to Unity instance creation
jeffreylanters Jul 16, 2025
cb07eed
Enable unload functionality in Application component
jeffreylanters Jul 16, 2025
1711afa
Add unload method to UnityContext for resource cleanup
jeffreylanters Jul 16, 2025
22b119d
Add unload method to useUnityContext for resource cleanup
jeffreylanters Jul 16, 2025
22373a8
Enable cache control in Unity instance configuration
jeffreylanters Jul 16, 2025
7717fe9
Add cacheControl to UnityProvider type definition
jeffreylanters Jul 16, 2025
f24c83b
Add cacheControl to UnityConfig type definition
jeffreylanters Jul 16, 2025
e8dd549
Fix documentation and ensure cacheControl is included in UnityProvide…
jeffreylanters Jul 16, 2025
94e0c0d
Update Unity component to set loading state correctly and include cac…
jeffreylanters Jul 16, 2025
7a3a222
Refactor comments for unimplemented features and add TODOs for future…
jeffreylanters Jul 16, 2025
a83a496
Implement event listener functionality in Application component
jeffreylanters Jul 16, 2025
453c4f8
Import EventSystem to enhance UnityContext type definition
jeffreylanters Jul 16, 2025
ce56a88
Add EventSystem type definition for external React Unity events
jeffreylanters Jul 16, 2025
c063cc0
Add EventListener type definition for handling Unity events
jeffreylanters Jul 16, 2025
7f2f43c
Add event system integration to useUnityContext for managing Unity ev…
jeffreylanters Jul 16, 2025
e22d5ee
Implement useEventSystem hook for managing external React Unity events
jeffreylanters Jul 16, 2025
64c2403
Add Unity communication loader and WebAssembly binary
jeffreylanters Jul 16, 2025
8bb5f98
Update Unity build paths and enable autoSyncPersistentDataPath
jeffreylanters Jul 16, 2025
a8ee686
Add autoSyncPersistentDataPath to UnityProvider type definition
jeffreylanters Jul 16, 2025
1fb0083
Update UnityProps type to include matchWebGLToCanvasSize and disabled…
jeffreylanters Jul 16, 2025
a152267
Add autoSyncPersistentDataPath to UnityConfig type definition
jeffreylanters Jul 16, 2025
1d6a831
Add autoSyncPersistentDataPath to UnityProvider instance in useUnityC…
jeffreylanters Jul 16, 2025
49faffc
Add autoSyncPersistentDataPath, matchWebGLToCanvasSize, and disabledC…
jeffreylanters Jul 16, 2025
a3ab645
Add className and tabIndex properties to canvas element in Applicatio…
jeffreylanters Jul 16, 2025
fa5fc6d
Add className and tabIndex properties to UnityProps type definition
jeffreylanters Jul 16, 2025
5ecc124
Add className and tabIndex properties to Unity component
jeffreylanters Jul 16, 2025
53c4f53
Migrating documentation to version 10
jeffreylanters Jul 16, 2025
20bbf90
chore: update dependencies and version to 1.0.5
jeffreylanters Jul 16, 2025
d59cc11
docs: update unload documentation to reflect changes in React Unity W…
jeffreylanters Jul 16, 2025
398d9f7
fix: restore unload documentation in API sidebar
jeffreylanters Jul 16, 2025
337f92c
docs: update release notes for React Unity WebGL version 10.0.0
jeffreylanters Jul 16, 2025
3b474a5
Resolved documentation migration links
jeffreylanters Jul 16, 2025
105f57d
docs: update introduction and support pages to reflect new contact in…
jeffreylanters Jul 16, 2025
0e63a63
docs: add upgrading guide for version 9
jeffreylanters Jul 16, 2025
5879fdb
docs: add upgrading guide for version 10 and update sidebar reference
jeffreylanters Jul 16, 2025
29a1b5c
docs: update package dependencies for Unity modules and improve versi…
jeffreylanters Jul 16, 2025
7664832
docs: update EditorBuildSettings and ProjectVersion for new scene con…
jeffreylanters Jul 16, 2025
02c04db
Upgraded testing build to one from Unity 6
jeffreylanters Jul 16, 2025
a0c3926
feat: add SystemInfo type definition and integrate it into UnityModule
jeffreylanters Jul 16, 2025
a92c392
feat: add UnitySystemInfo type definition and update UnityModule inte…
jeffreylanters Jul 16, 2025
49f4da8
feat: add UnityMetricsInfo type definition and integrate it into Unit…
jeffreylanters Jul 16, 2025
492cf4f
feat: replace UnityInstanceBannerType with UnityBannerType in UnityAr…
jeffreylanters Jul 16, 2025
2e0c827
feat: add MetricsConfig type definition and update UnityInstance prop…
jeffreylanters Jul 16, 2025
a49185b
feat: integrate useUnityMetricsInfo to display FPS in Application com…
jeffreylanters Jul 16, 2025
ac1edf5
feat: export useUnityMetricsInfo from exports.ts
jeffreylanters Jul 16, 2025
b361396
feat: make all properties of UnityMetricsInfo optional
jeffreylanters Jul 16, 2025
6829e49
feat: add getMetricsInfo method to UnityContext for performance metrics
jeffreylanters Jul 16, 2025
0f349c1
docs: update MetricsConfig type definition to clarify default interva…
jeffreylanters Jul 16, 2025
6645575
feat: implement useUnityMetricsInfo hook for retrieving Unity metrics
jeffreylanters Jul 16, 2025
b1b7fc6
feat: add getMetricsInfo method to retrieve performance metrics from …
jeffreylanters Jul 16, 2025
2d2bc41
chore: update version to 10.1.0 in package.json and package-lock.json
jeffreylanters Jul 16, 2025
a03c1b7
docs: update example title for using the unload function in documenta…
jeffreylanters Jul 16, 2025
51b4b51
docs: update example usage to clarify stopping the Unity Application
jeffreylanters Jul 16, 2025
557c437
docs: add documentation for compressed builds and server configuratio…
jeffreylanters Jul 16, 2025
ecc12c8
fix: correct typo in ID for compression and server configuration docu…
jeffreylanters Jul 16, 2025
e137b4d
docs: add label for upgrading documentation section
jeffreylanters Jul 16, 2025
61779e1
docs: update unloading issue explanation in upgrading documentation
jeffreylanters Jul 16, 2025
a1276c1
docs: add metrics info documentation and update sidebar for debugging…
jeffreylanters Jul 16, 2025
5b4cd47
docs: update release notes to include Unity Metrics Info API and perf…
jeffreylanters Jul 16, 2025
9e6b6eb
Added profiling example to front-page
jeffreylanters Jul 16, 2025
f596ac2
docs: add tutorials for using Unity WebGL with React
jeffreylanters Jul 16, 2025
4119c14
docs: update announcement bar message and background color; add tutor…
jeffreylanters Jul 16, 2025
ed0c910
fix: use default cache control if not provided in Unity props
jeffreylanters Jul 16, 2025
d82dbb2
feat: add default cache control function for Unity WebGL builds
jeffreylanters Jul 16, 2025
2c07567
feat: add default WebGL context attributes constant
jeffreylanters Jul 16, 2025
624116e
feat: use default WebGL context attributes if not provided in Unity p…
jeffreylanters Jul 16, 2025
69b8544
chore: update version to 10.1.1 in package.json and package-lock.json
jeffreylanters Jul 16, 2025
1dcd8e5
fix: update release notes to reflect resolution of cache control and …
jeffreylanters Jul 16, 2025
24e13f0
feat: add demo link to the navigation bar in docusaurus config
jeffreylanters Jul 18, 2025
e38071e
fix: update version label to specify "Version 10 (Current)" in docusa…
jeffreylanters Jul 18, 2025
04145c9
refactor: remove default cache control and WebGL context attributes c…
jeffreylanters Jul 19, 2025
849e49a
update company name from in application configuration
jeffreylanters Jul 19, 2025
b0d2265
refactor: streamline UnityProps type definition by consolidating canv…
jeffreylanters Jul 19, 2025
b11fc83
fix: correct import statement for RefAttributes in Unity component
jeffreylanters Jul 19, 2025
2372def
refactor: enhance UnitySystemInfo type definition with additional com…
jeffreylanters Jul 19, 2025
0cfe842
refactor: reorganize UnityMetricsInfo type definition for improved re…
jeffreylanters Jul 19, 2025
facec05
refactor: enhance UnityBannerType definition with additional comments…
jeffreylanters Jul 19, 2025
0b52d19
refactor: format requestPointerLock function for improved readability
jeffreylanters Jul 19, 2025
8d65cb6
refactor: add onSuccess and onError parameters to createUnityInstance…
jeffreylanters Jul 21, 2025
c12c325
refactor: remove unnecessary console.log statement from Unity component
jeffreylanters Jul 21, 2025
558c964
refactor: enhance documentation for UnityProvider methods for clarity
jeffreylanters Jul 21, 2025
cafc343
refactor: improve documentation for UnityProvider interface for bette…
jeffreylanters Jul 21, 2025
367c47c
refactor: update cache control method in RELEASE-NOTES for improved c…
jeffreylanters Jul 21, 2025
5dad55c
chore: update version to 10.1.2 in package.json and package-lock.json
jeffreylanters Jul 21, 2025
60491db
fix: exporting internal types as the correct file types
jeffreylanters Jul 21, 2025
d9ce772
refactor: expand exported types in exports.ts for improved type acces…
jeffreylanters Jul 21, 2025
d249339
fix: add note about resolving internal type export issues in RELEASE-…
jeffreylanters Jul 21, 2025
f38760d
chore: update version to 10.1.3 in package.json and package-lock.json
jeffreylanters Jul 21, 2025
f351ba1
fix: remove outdated note about cache control method in RELEASE-NOTES
jeffreylanters Jul 21, 2025
0451325
fix: add UnityMessageParameter to exports for improved type accessibi…
jeffreylanters Jul 21, 2025
ce4b953
fix: update parameter type in SendMessage to UnityMessageParameter fo…
jeffreylanters Jul 21, 2025
621a7bf
feat: add UnityMessageParameter type declaration for flexible message…
jeffreylanters Jul 21, 2025
3abbecf
fix: revert UnityEventParameter type to 'any' for broader compatibility
jeffreylanters Jul 21, 2025
5d9d1c7
fix: update sendMessage parameter type to UnityMessageParameter for c…
jeffreylanters Jul 21, 2025
39b0572
fix: update parameter type in useUnityContext to UnityMessageParamete…
jeffreylanters Jul 21, 2025
2d1bab9
fix: update RELEASE-NOTES to clarify separation of Unity Message and …
jeffreylanters Jul 21, 2025
5f39e10
fix: bump version to 10.1.4 in package.json
jeffreylanters Jul 21, 2025
3ba6e8c
fix: update ReactUnityEventParameter type to 'any' for broader compat…
jeffreylanters Jul 21, 2025
cf89222
fix: update sendMessage parameter type to UnityMessageParameter for c…
jeffreylanters Jul 21, 2025
0f4a15b
fix: update dispatchReactUnityEvent parameter type to UnityEventParam…
jeffreylanters Jul 21, 2025
ed18026
Added vite build script
jeffreylanters Jul 29, 2025
14f7d76
fix: hide cleanup canvas element to prevent display issues
jeffreylanters Jul 30, 2025
afc9ba3
fix: update version to 10.1.5 in package.json and package-lock.json
jeffreylanters Jul 30, 2025
275a08b
fix: update release notes to reflect changes in cleanup canvas visibi…
jeffreylanters Jul 30, 2025
f5cb29b
fix: update typescript version to 5.9.3 in package.json and package-l…
jeffreylanters Oct 14, 2025
35599ca
fix: update version to 10.1.6 in package.json and package-lock.json
jeffreylanters Oct 14, 2025
19c8da3
fix: update release notes to reflect TypeScript version and package u…
jeffreylanters Oct 14, 2025
65d65a4
fix: add UnityBannerType to exports and type exports
jeffreylanters May 8, 2026
8cec311
fix: add showBanner, print, and printErr to Unity component props
jeffreylanters May 8, 2026
95ac514
fix: add showBanner, print, and printErr to Unity context configuration
jeffreylanters May 8, 2026
c2ce059
fix: add showBanner, print, and printErr to UnityConfig type
jeffreylanters May 8, 2026
b70fef5
fix: add showBanner, print, and printErr to UnityProvider type
jeffreylanters May 8, 2026
c6d622a
fix: implement print, printErr, and showBanner handlers in Applicatio…
jeffreylanters May 8, 2026
efe51b3
docs: add Print Errors API documentation
jeffreylanters May 8, 2026
685aa15
docs: add Print API documentation to describe logging functionality
jeffreylanters May 8, 2026
b77c398
docs: add Show Banner API documentation for custom UI integration
jeffreylanters May 8, 2026
623e3ba
docs: add Print, Print Errors, and Show Banner API documentation link…
jeffreylanters May 8, 2026
654dfee
Updated various package dependencies
jeffreylanters May 8, 2026
4d8b32f
fix: update TypeScript target from es5 to es6
jeffreylanters May 8, 2026
47536d7
docs: update RELEASE-NOTES with TypeScript target change and new Unit…
jeffreylanters May 8, 2026
d7142aa
chore: update version from 10.1.6 to 10.2.0 in package.json and packa…
jeffreylanters May 8, 2026
6065389
Removed publish automation
jeffreylanters May 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 0 additions & 79 deletions .github/workflows/publish-module.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/validate-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
registry-url: https://registry.npmjs.org
# Cache Node Module Dependencies
- name: Cache Node Module Dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: "documentation/node_modules"
key: nodemodules-${{ runner.os }}-${{ hashFiles('documentation/package-lock.json') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
registry-url: https://registry.npmjs.org
# Cache Node Module Dependencies
- name: Cache Node Module Dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: "module/node_modules"
key: nodemodules-${{ runner.os }}-${{ hashFiles('module/package-lock.json') }}
Expand Down
1 change: 0 additions & 1 deletion RELEASE-NOTES.md

This file was deleted.

4 changes: 2 additions & 2 deletions documentation/docs/api/event-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ function removeEventListener(
```tsx title="Type Definition"
function dispatchReactUnityEvent(
eventName: string,
...parameters: ReactUnityEventParameterType[]
...parameters: UnityEventParameter[]
): void;
```

```tsx title="Type Definition"
type ReactUnityEventParameter = string | number | undefined;
type UnityEventParameter = any | undefined | void;
```

## Implementation
Expand Down
71 changes: 71 additions & 0 deletions documentation/docs/api/get-metrics-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Getting Metrics Info

The `getMetricsInfo` function is used to retrieve information about the Unity Application's metrics, such as memory usage and frame rate. This can be useful for debugging and performance analysis.

:::tip
Use the built-in [Unity Metrics Info hook](/docs/api/use-unity-metrics-info) for a more convenient way to access metrics information in your React components.
:::

## Type Definition

```tsx title="Type Definition"
function getMetricsInfo(): UnityMetricsInfo | undefined;
```

## Implementation

:::info
The getMetricsInfo function is only available in Unity Builds created with Unity 6000.1 or later.
:::

Web builds can get quite large, and it can be useful to know how much memory is being used by the Unity Application. The `getMetricsInfo` function provides a way to retrieve this information. It returns an object containing various metrics, such as memory usage, frame rate, and more.

To get started, destructure the getMetricsInfo function from the Unity Context.

```jsx showLineNumbers title="Example: Destructuring the unload function"
const { getMetricsInfo } = useUnityContext();
```

Next you'll be able to invoke the `getMetricsInfo` function to retrieve the metrics information. The function returns an object of type `UnityMetricsInfo`, which contains various properties related to the Unity Application's performance.

```jsx showLineNumbers title="Example: Using the get metrics info function"
async function handleClick() {
const metricsInfo = getMetricsInfo();
}

return <button onClick={handleClick}>Check metrics</button>;
```

## Example Usage

A basic implementation could look something like this. In the following example we'll display a button which allows us to check the current frames per second (FPS) of the Unity Application. When the button is clicked, it will log the FPS to the console.

```jsx showLineNumbers title="App.jsx"
import React, { Fragment } from "react";
import { Unity, useUnityContext } from "react-unity-webgl";

function App() {
const { unityProvider, getMetricsInfo } = useUnityContext({
loaderUrl: "build/myunityapp.loader.js",
dataUrl: "build/myunityapp.data",
frameworkUrl: "build/myunityapp.framework.js",
codeUrl: "build/myunityapp.wasm",
});

function handleClickCheckFps() {
const metricsInfo = getMetricsInfo();
if (metricsInfo) {
console.log("FPS:", metricsInfo.fps);
} else {
console.warn("Metrics info is not available.");
}
}

return (
<Fragment>
<Unity unityProvider={unityProvider} />
<button onClick={handleClickCheckFps}>Check FPS</button>
</Fragment>
);
}
```
49 changes: 49 additions & 0 deletions documentation/docs/api/print-err.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Print Errors

The Print Errors API lets you intercept all error output coming out of the Unity Module — runtime errors, JavaScript errors thrown from `jslib` files, and `Debug.LogError` calls from your C# code — before they reach the browser console.

## Type Definition

```tsx title="Type Definition"
function printErr(message: string): void;
```

## Implementation

By default, Unity routes its error output through `console.error`. When a `printErr` handler is provided to the Unity Config, Unity will call your handler instead of writing to the console directly. This is the counterpart to [Print](./print.md) and is the recommended channel for forwarding Unity errors into custom logging, error reporting (e.g. Sentry), or an in-app diagnostics panel.

Both runtime problems thrown by the engine and `jslib`/JavaScript errors flow through this handler.

:::info
The handler is captured once during initialisation and passed to `createUnityInstance`. Changing the function reference after the Unity Instance has booted will not have any effect, so prefer a stable reference (for example via `useCallback` or a module-scope function).
:::

:::caution
The handler replaces the default console output. If you still want messages in the browser console, call `console.error` from inside your handler.
:::

## Example Usage

A basic implementation could look something like this. In the following example we'll forward every Unity error to both the console and an error reporting service.

```jsx {5-8,15} showLineNumbers title="App.jsx"
import React from "react";
import { Unity, useUnityContext } from "react-unity-webgl";

function App() {
function handlePrintErr(message) {
console.error("[Unity]", message);
errorReporter.captureMessage(message, { level: "error" });
}

const { unityProvider } = useUnityContext({
loaderUrl: "build/myunityapp.loader.js",
dataUrl: "build/myunityapp.data",
frameworkUrl: "build/myunityapp.framework.js",
codeUrl: "build/myunityapp.wasm",
printErr: handlePrintErr,
});

return <Unity unityProvider={unityProvider} />;
}
```
49 changes: 49 additions & 0 deletions documentation/docs/api/print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Print

The Print API lets you intercept all standard log output coming out of the Unity Module — both internal information messages from the loader and runtime, and `Debug.Log` calls from your C# code — before they reach the browser console.

## Type Definition

```tsx title="Type Definition"
function print(message: string): void;
```

## Implementation

By default, Unity routes its standard output through `console.log`. When a `print` handler is provided to the Unity Config, Unity will call your handler instead of writing to the console directly. This is useful for forwarding Unity logs into a custom logger, dev tools panel, telemetry sink, or in-app debug overlay.

Both internal Unity messages (loader progress, framework diagnostics) and your own `Debug.Log` calls flow through this handler.

:::info
The handler is captured once during initialisation and passed to `createUnityInstance`. Changing the function reference after the Unity Instance has booted will not have any effect, so prefer a stable reference (for example via `useCallback` or a module-scope function).
:::

:::caution
The handler replaces the default console output. If you still want messages in the browser console, call `console.log` from inside your handler.
:::

## Example Usage

A basic implementation could look something like this. In the following example we'll forward every Unity log message to both the console and a telemetry function.

```jsx {5-8,15} showLineNumbers title="App.jsx"
import React from "react";
import { Unity, useUnityContext } from "react-unity-webgl";

function App() {
function handlePrint(message) {
console.log("[Unity]", message);
telemetry.capture({ severity: "info", message });
}

const { unityProvider } = useUnityContext({
loaderUrl: "build/myunityapp.loader.js",
dataUrl: "build/myunityapp.data",
frameworkUrl: "build/myunityapp.framework.js",
codeUrl: "build/myunityapp.wasm",
print: handlePrint,
});

return <Unity unityProvider={unityProvider} />;
}
```
6 changes: 3 additions & 3 deletions documentation/docs/api/send-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ The send message function lets you asynchronously invoke a method in the Unity g
function sendMessage(
gameObjectName: string,
methodName: string,
parameter?: ReactUnityEventParameterType
parameter?: UnityMessageParameter
): void;
```

```tsx title="Type Definition"
type ReactUnityEventParameter = string | number | undefined;
type UnityMessageParameter = string | number | undefined | void;
```

## Implementation
Expand All @@ -32,7 +32,7 @@ When invoking a C-Sharp method by sending a message, the name of the mono behavi
:::

:::warning
Make sure the parameter matches the actual existence and type of the C-Sharp method you're trying to invoke. Not
Make sure the parameter matches the actual existence and type of the C-Sharp method you're trying to invoke. Not
doing so may cause unintended behaviour or even a crash of the Unity Application.
:::

Expand Down
72 changes: 72 additions & 0 deletions documentation/docs/api/show-banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Show Banner

The Show Banner API allows you to intercept non-critical warnings and error messages from the Unity Instance and route them into your own UI instead of relying on Unity's default in-DOM banner.

## Type Definition

```tsx title="Type Definition"
function showBanner(message: string, type?: UnityBannerType): void;
```

```tsx title="Type Definition"
type UnityBannerType = "error" | "warning";
```

## Implementation

When the Unity Instance encounters a non-critical issue it would normally display a banner directly in the DOM, above the canvas. By providing a `showBanner` handler to the Unity Config you take ownership of that signal — Unity will call your handler with the message and an optional type instead of rendering its own banner.

This is the official way (supported since Unity 6.3) to surface Unity warnings and recoverable errors inside your React UI, for example as a toast, a banner of your own, or a telemetry event.

- `message` is the human readable text Unity wanted to display.
- `type` is `"error"` or `"warning"`. It may be `undefined` for messages that do not carry a severity.

:::info
The handler is captured once during initialisation and passed to `createUnityInstance`. Changing the function reference after the Unity Instance has booted will not have any effect, so prefer a stable reference (for example via `useCallback` or a module-scope function).
:::

## Example Usage

A basic implementation could look something like this. In the following example we'll route warnings and errors to a piece of React state which renders a custom banner above the Unity canvas.

```jsx {6-8,15} showLineNumbers title="App.jsx"
import React, { useState } from "react";
import { Unity, useUnityContext } from "react-unity-webgl";

function App() {
const [banner, setBanner] = useState(null);

function handleShowBanner(message, type) {
setBanner({ message, type: type ?? "info" });
}

const { unityProvider } = useUnityContext({
loaderUrl: "build/myunityapp.loader.js",
dataUrl: "build/myunityapp.data",
frameworkUrl: "build/myunityapp.framework.js",
codeUrl: "build/myunityapp.wasm",
showBanner: handleShowBanner,
});

return (
<>
{banner && (
<div role="alert" data-severity={banner.type}>
{banner.message}
</div>
)}
<Unity unityProvider={unityProvider} />
</>
);
}
```

When using TypeScript, the `UnityBannerType` is exported from the package so you can type your handler explicitly.

```tsx showLineNumbers title="App.tsx"
import { UnityBannerType } from "react-unity-webgl";

function handleShowBanner(message: string, type?: UnityBannerType) {
// ...
}
```
Loading