unity-webgl
Advanced tools
Comparing version
/** | ||
* UnityWebgl configuration | ||
* Unity Boolean Like Type Declaration. | ||
*/ | ||
type UnityConfig = Pick<UnityArguments, 'dataUrl' | 'frameworkUrl' | 'codeUrl' | 'streamingAssetsUrl' | 'memoryUrl' | 'symbolsUrl' | 'companyName' | 'productName' | 'productVersion' | 'devicePixelRatio' | 'matchWebGLToCanvasSize' | 'webglContextAttributes'> & { | ||
/** | ||
* The url to the build json file generated by Unity. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* @public | ||
* @type {string} | ||
*/ | ||
readonly loaderUrl: string; | ||
}; | ||
type UnityBooleanLike = | ||
/** | ||
* unity instance configuration | ||
* Represents the boolean value `false`. | ||
*/ | ||
interface UnityArguments { | ||
0 | ||
/** | ||
* Represents the boolean value `true`. | ||
*/ | ||
| 1; | ||
type UnityModule = { | ||
/** | ||
* The url to the build data file generated by Unity. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* @public | ||
* @type {string} | ||
* Stringifies a pointer to a string. | ||
* @param pointer The pointer to the string. | ||
* @param length The length of the string. | ||
* @deprecated Deprecated in Unity 2021.2, use UTF8ToString instead. | ||
*/ | ||
readonly dataUrl: string; | ||
Pointer_stringify(pointer: number, length: number): string; | ||
/** | ||
* The url to the framework file generated by Unity. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* @public | ||
* @type {string} | ||
* Converts a pointer to a string. | ||
* @param pointer The pointer to the string. | ||
*/ | ||
readonly frameworkUrl: string; | ||
UTF8ToString(pointer: number): string; | ||
/** | ||
* The url to the unity code file generated by Unity. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* @public | ||
* @type {string} | ||
* Enables or disabled the fullscreen mode of the UnityInstance. | ||
* @param fullScreen sets the fullscreen mode. | ||
*/ | ||
readonly codeUrl: string; | ||
SetFullscreen(fullScreen: UnityBooleanLike): void; | ||
/** | ||
* The url where the streaming assets can be found. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* @public | ||
* @type {string} | ||
* A reference to the Unity Instance's Canvas. | ||
*/ | ||
readonly streamingAssetsUrl?: string; | ||
canvas?: HTMLCanvasElement; | ||
}; | ||
/** | ||
* Type declaration for the UnityInstance. | ||
*/ | ||
declare class UnityInstance { | ||
/** | ||
* The url to the framework file generated by Unity. When using a relative url, | ||
* keep in mind this is relative from the path where your html file is served. | ||
* It is also possible to use an absolute url, for example when using a CDN. | ||
* This is set to the memory file when memory is stored in an external file, | ||
* otherwise it is set to an empty string. | ||
* @public | ||
* @type {string} | ||
* Creates a new instance of Unity Instance. | ||
*/ | ||
readonly memoryUrl?: string; | ||
constructor(); | ||
/** | ||
* The url to the unity code file generated by Unity. When using a relative | ||
* url, keep in mind this is relative from the path where your html file is | ||
* served. It is also possible to use an absolute url, for example when using | ||
* a CDN. This is set to the JSON file containing debug symbols when the | ||
* current build is using debug symbols, otherwise it is set to an empty string. | ||
* @public | ||
* @type {string} | ||
* Sends a message to the UnityInstance to invoke a public method. | ||
* @param objectName the name of the game object in your Unity scene. | ||
* @param methodName the name of the public method on the game object. | ||
* @param parameter an optional parameter to pass along to the method. | ||
*/ | ||
readonly symbolsUrl?: string; | ||
SendMessage(objectName: string, methodName: string, parameter?: string | number | boolean): void; | ||
/** | ||
* The application's company name. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @type {string} | ||
* Enables or disabled the fullscreen mode of the UnityInstance. | ||
* @param fullScreen sets the fullscreen mode. | ||
*/ | ||
readonly companyName?: string; | ||
SetFullscreen(fullScreen: UnityBooleanLike): void; | ||
/** | ||
* The application's product name. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @type {string} | ||
* Quits the Unity WebGL application and removes it from the memory. | ||
* @returns a promise which resolves when the application did quit. | ||
*/ | ||
readonly productName?: string; | ||
Quit(): Promise<void>; | ||
/** | ||
* The application's product version. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @type {string} | ||
* The internal Unity Module. | ||
*/ | ||
readonly productVersion?: string; | ||
Module: UnityModule; | ||
} | ||
interface EventListener { | ||
(...args: any[]): void; | ||
_?: EventListener; | ||
} | ||
type EventListenerOptions = { | ||
once?: boolean; | ||
}; | ||
interface UnityEventMap { | ||
beforeMount: (instance: UnityWebgl) => void; | ||
mounted: (instance: UnityWebgl, unityInstance: UnityInstance) => void; | ||
beforeUnmount: (instance: UnityWebgl) => void; | ||
unmounted: () => void; | ||
progress: (progress: number) => void; | ||
debug: (msg: string) => void; | ||
error: (error: string | Error) => void; | ||
} | ||
declare class UnityWebglEvent { | ||
private _e; | ||
constructor(); | ||
/** | ||
* The Canvas can appear too blurry on retina screens. The devicePixelRatio | ||
* determines how much extra pixel density should be added to allow for a | ||
* sharper image. | ||
* @public | ||
* @type {string} | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | ||
* Register event listener | ||
* @param name event name | ||
* @param listener event listener | ||
* @param options event listener options | ||
*/ | ||
readonly devicePixelRatio?: number; | ||
on<K extends keyof UnityEventMap>(name: K, listener: UnityEventMap[K], options?: EventListenerOptions): this; | ||
on(name: string, listener: EventListener, options?: EventListenerOptions): this; | ||
/** | ||
* When disabling the match WebGL to canvas size flag, the canvas allows for | ||
* client side customization of the WebGL canvas target size instead of | ||
* requiring it to always match 1:1 with the High DPI CSS size of the canvas. | ||
* Supported since Unity 2021.1b | ||
* @public | ||
* @type {boolean} | ||
* @see https://issuetracker.unity3d.com/issues/webgl-builds-dont-allow-separate-control-on-canvas-render-buffer-size | ||
* Remove event listener | ||
* @param name event name | ||
* @param listener event listener | ||
*/ | ||
readonly matchWebGLToCanvasSize?: boolean; | ||
off<K extends keyof UnityEventMap>(name: K, listener: UnityEventMap[K]): this; | ||
off(name: string, listener: EventListener): this; | ||
/** | ||
* This object allow you to configure WebGLRenderingContext creation options | ||
* which will be pass additional context attributes to the Unity canvas. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext | ||
* @public | ||
* @type {IWebGLContextAttributes} | ||
* Dispatch event | ||
* @param name event name | ||
* @param args event args | ||
*/ | ||
readonly webglContextAttributes?: IWebGLContextAttributes; | ||
emit(name: string, ...args: any[]): this; | ||
/** | ||
* When assigned this method will intercept all incomming messages from the | ||
* Unity Module into the console. These messages will contain both of the | ||
* internal information messages as well as the debuggers log messages. | ||
* clear all event listeners | ||
*/ | ||
print?: (message: string) => void; | ||
protected clear(): void; | ||
/** | ||
* When assigned this method will intercept all incomming error logs from the | ||
* Unity Module into the console. These messages will contain both of the | ||
* runtime problems as well as the jslib and javascript errors thrown by the | ||
* Unity Instance. | ||
* Register event listener for unity client | ||
* @param name event name | ||
* @param listener event listener | ||
*/ | ||
printError?: (message: string) => void; | ||
addUnityListener(name: string, listener: EventListener, options?: EventListenerOptions): this; | ||
/** | ||
* Remove event listener from unity client | ||
* @param name event name | ||
* @param listener event listener | ||
*/ | ||
removeUnityListener(name: string, listener?: EventListener): this; | ||
} | ||
/** | ||
@@ -131,3 +129,3 @@ * WebGLContextAttributes object that contains the actual context parameters. | ||
*/ | ||
type IWebGLContextAttributes = { | ||
type WebGLContextAttributes = { | ||
/** | ||
@@ -212,119 +210,191 @@ * If set to true, the context will have an alpha (transparency) channel. | ||
}; | ||
type UnityBooleanLike = 0 | 1; | ||
type UnityModule = { | ||
/** | ||
* The cache control mode determines how the Unity should cache the resource. | ||
* - `must-revalidate`: The cache returns to an enabled state and the file is | ||
* revalidated before being loaded from the cache. | ||
* - `immutable`: the cache is enabled and the file is loaded from the cache | ||
* without revalidation. | ||
* - `no-store`: The cache is disabled. | ||
*/ | ||
type UnityCacheControlMode = | ||
/** | ||
* The cache returns to an enabled state and the file is revalidated before | ||
* being loaded from the cache. | ||
*/ | ||
'must-revalidate' | ||
/** | ||
* the cache is enabled and the file is loaded from the cache without revalidation. | ||
*/ | ||
| 'immutable' | ||
/** | ||
* The cache is disabled. | ||
*/ | ||
| 'no-store' | ||
/** | ||
* Fallback for when the cache control mode is not recognized. | ||
*/ | ||
| string; | ||
/** | ||
* Banners can be used to display non-critical warnings and error messages from | ||
* the Unity Instance. | ||
*/ | ||
type UnityInstanceBannerType = 'error' | 'warning'; | ||
/** | ||
* The Unity Arguments can be passed to a create Unity instance method in order to initialize it. | ||
*/ | ||
interface UnityArguments { | ||
/** | ||
* Stringifies a pointer to a string. | ||
* @param pointer The pointer to the string. | ||
* @param length The length of the string. | ||
* @deprecated Deprecated in Unity 2021.2, use UTF8ToString instead. | ||
* The url to the build data file generated by Unity. | ||
* @public | ||
* @type {string} | ||
*/ | ||
Pointer_stringify(pointer: number, length: number): string; | ||
readonly dataUrl: string; | ||
/** | ||
* Converts a pointer to a string. | ||
* @param pointer The pointer to the string. | ||
* The url to the framework file generated by Unity. | ||
* @public | ||
* @type {string} | ||
*/ | ||
UTF8ToString(pointer: number): string; | ||
readonly frameworkUrl: string; | ||
/** | ||
* Enables or disabled the fullscreen mode of the UnityInstance. | ||
* @param fullScreen sets the fullscreen mode. | ||
* The url to the unity code file generated by Unity. | ||
* @public | ||
* @type {string} | ||
*/ | ||
SetFullscreen(fullScreen: UnityBooleanLike): void; | ||
readonly codeUrl: string; | ||
/** | ||
* A reference to the Unity Instance's Canvas. | ||
* The url to the web worker file generated by Unity. | ||
* @public | ||
* @type {string} | ||
*/ | ||
canvas?: HTMLCanvasElement; | ||
}; | ||
/** | ||
* Type declaration for the UnityInstance. | ||
*/ | ||
declare class UnityInstance { | ||
readonly workerUrl?: string; | ||
/** | ||
* Creates a new instance of Unity Instance. | ||
* The url where the streaming assets can be found. | ||
* @public | ||
* @type {string} | ||
*/ | ||
constructor(); | ||
readonly streamingAssetsUrl?: string; | ||
/** | ||
* Sends a message to the UnityInstance to invoke a public method. | ||
* The url to the framework file generated by Unity. | ||
* This is set to the memory file when memory is stored in an external file, | ||
* otherwise it is set to an empty string. | ||
* @public | ||
* @param objectName the name of the game object in your Unity scene. | ||
* @param methodName the name of the public method on the game object. | ||
* @param parameter an optional parameter to pass along to the method. | ||
* @type {string} | ||
*/ | ||
SendMessage(objectName: string, methodName: string, parameter?: string | number | boolean): void; | ||
readonly memoryUrl?: string; | ||
/** | ||
* Enables or disabled the fullscreen mode of the UnityInstance. | ||
* The url to the unity code file generated by Unity. | ||
* This is set to the JSON file containing debug symbols when the | ||
* current build is using debug symbols, otherwise it is set to an empty string. | ||
* @public | ||
* @param fullScreen sets the fullscreen mode. | ||
* @type {string} | ||
*/ | ||
SetFullscreen(fullScreen: UnityBooleanLike): void; | ||
readonly symbolsUrl?: string; | ||
/** | ||
* Quits the Unity WebGL application | ||
* and removes it from the memory. | ||
* The application's company name. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @returns {Promise<void>} a promise whether the application did quit. | ||
* @type {string} | ||
*/ | ||
Quit(): Promise<void>; | ||
readonly companyName?: string; | ||
/** | ||
* The Unity Module. | ||
* The application's product name. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @type {string} | ||
*/ | ||
Module: UnityModule; | ||
} | ||
interface EventListener { | ||
(...args: any[]): void; | ||
_?: EventListener; | ||
} | ||
type EventListenerOptions = { | ||
once?: boolean; | ||
}; | ||
interface UnityEventMap { | ||
beforeMount: (instance: UnityWebgl) => void; | ||
mounted: (instance: UnityWebgl, unityInstance: UnityInstance) => void; | ||
beforeUnmount: (instance: UnityWebgl) => void; | ||
unmounted: () => void; | ||
progress: (progress: number) => void; | ||
debug: (msg: string) => void; | ||
error: (error: string | Error) => void; | ||
} | ||
declare class UnityWebglEvent { | ||
private _e; | ||
constructor(); | ||
readonly productName?: string; | ||
/** | ||
* Register event listener | ||
* @param name event name | ||
* @param listener event listener | ||
* @param options event listener options | ||
* The application's product version. This argument is treated as meta data | ||
* which will be provided to the Unity Instance. | ||
* @public | ||
* @type {string} | ||
*/ | ||
on<K extends keyof UnityEventMap>(name: K, listener: UnityEventMap[K], options?: EventListenerOptions): this; | ||
on(name: string, listener: EventListener, options?: EventListenerOptions): this; | ||
readonly productVersion?: string; | ||
/** | ||
* Remove event listener | ||
* @param name event name | ||
* @param listener event listener | ||
* The Canvas can appear too blurry on retina screens. The devicePixelRatio | ||
* determines how much extra pixel density should be added to allow for a | ||
* sharper image. | ||
* @public | ||
* @type {string} | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | ||
*/ | ||
off<K extends keyof UnityEventMap>(name: K, listener: UnityEventMap[K]): this; | ||
off(name: string, listener: EventListener): this; | ||
readonly devicePixelRatio?: number; | ||
/** | ||
* Dispatch event | ||
* @param name event name | ||
* @param args event args | ||
* If set to true, all file writes inside the Unity Application | ||
* persistentDataPath directory automatically persist so that the contents are | ||
* remembered when the user revisits the website the next time. If unset (or | ||
* set to false), you must manually sync file modifications inside the | ||
* Application persistentDataPath directory by calling the | ||
* JS_FileSystem_Sync() JavaScript function. | ||
*/ | ||
emit(name: string, ...args: any[]): this; | ||
readonly autoSyncPersistentDataPath?: boolean; | ||
/** | ||
* clear all event listeners | ||
* When disabling the match WebGL to canvas size flag, the canvas allows for | ||
* client side customization of the WebGL canvas target size instead of | ||
* requiring it to always match 1:1 with the High DPI CSS size of the canvas. | ||
* Supported since Unity 2021.1b | ||
* @public | ||
* @type {boolean} | ||
* @see https://issuetracker.unity3d.com/issues/webgl-builds-dont-allow-separate-control-on-canvas-render-buffer-size | ||
*/ | ||
protected clear(): void; | ||
readonly matchWebGLToCanvasSize?: boolean; | ||
/** | ||
* Register event listener for unity client | ||
* @param name event name | ||
* @param listener event listener | ||
* This object allow you to configure WebGLRenderingContext creation options | ||
* which will be pass additional context attributes to the Unity canvas. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext | ||
*/ | ||
addUnityListener(name: string, listener: EventListener, options?: EventListenerOptions): this; | ||
readonly webglContextAttributes?: WebGLContextAttributes; | ||
/** | ||
* Remove event listener from unity client | ||
* @param name event name | ||
* @param listener event listener | ||
* An array of strings containing the names of the events that should be | ||
* disabled on the canvas. This can be useful when you want to allow the user | ||
* to interact with the canvas, but not with the Unity WebGL canvas. The | ||
* default disabled events are `contextmenu` and `dragstart`. | ||
*/ | ||
removeUnityListener(name: string, listener?: EventListener): this; | ||
readonly disabledCanvasEvents?: (keyof GlobalEventHandlersEventMap)[]; | ||
/** | ||
* By default, the WebGL Cache stores the asset data file .data and | ||
* AssetBundle files .bundle, and revalidates them before loading them from | ||
* the cache. You can change this behavior by overriding the default | ||
* caching behavior. This argument is treated as meta data which will be | ||
* provided to the Unity Instance. | ||
*/ | ||
readonly cacheControl?: (url: string) => UnityCacheControlMode; | ||
/** | ||
* Add an event listener using this function to receive non-critical warnings | ||
* and error messages from the Unity Instance. | ||
*/ | ||
readonly showBanner?: (message: string, type?: UnityInstanceBannerType) => void; | ||
/** | ||
* When assigned this method will intercept all incomming messages from the | ||
* Unity Module into the console. These messages will contain both of the | ||
* internal information messages as well as the debuggers log messages. | ||
*/ | ||
print?: (message: string) => void; | ||
/** | ||
* When assigned this method will intercept all incomming error logs from the | ||
* Unity Module into the console. These messages will contain both of the | ||
* runtime problems as well as the jslib and javascript errors thrown by the | ||
* Unity Instance. | ||
*/ | ||
printError?: (message: string) => void; | ||
} | ||
/** | ||
* Most of the Unity Config's properties are also part of the Unity Arguments. | ||
* This type is used to pick the properties that are configurable from the | ||
* Unity Arguments. | ||
*/ | ||
type ConfigurableUnityArguments = Pick<UnityArguments, 'dataUrl' | 'frameworkUrl' | 'codeUrl' | 'workerUrl' | 'streamingAssetsUrl' | 'memoryUrl' | 'symbolsUrl' | 'companyName' | 'productName' | 'productVersion' | 'webglContextAttributes' | 'cacheControl' | 'devicePixelRatio' | 'matchWebGLToCanvasSize' | 'disabledCanvasEvents' | 'autoSyncPersistentDataPath'>; | ||
/** | ||
* The Unity config is provided when instantiating a Unity context. This config | ||
* will eventually be used to create the Unity Arguments which will be passed | ||
* to the create Unity instance method in order to initialize it. | ||
*/ | ||
type UnityConfig = ConfigurableUnityArguments & { | ||
/** | ||
* The url to the build json file generated by Unity. | ||
*/ | ||
readonly loaderUrl: string; | ||
}; | ||
type CanvasElementOrString = HTMLCanvasElement | string; | ||
@@ -390,2 +460,2 @@ declare class UnityWebgl extends UnityWebglEvent { | ||
export { type IWebGLContextAttributes, type UnityArguments, type UnityConfig, UnityInstance, UnityWebgl as default }; | ||
export { type UnityArguments, type UnityConfig, UnityInstance, UnityWebgl as default }; |
/*! | ||
* unity-webgl v4.3.0 | ||
* unity-webgl v4.4.0 | ||
* Copyright (c) 2025 Mariner<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the Apache-2.0 License. |
/*! | ||
* unity-webgl v4.3.0 | ||
* unity-webgl v4.4.0 | ||
* Copyright (c) 2025 Mariner<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the Apache-2.0 License. |
/*! | ||
* unity-webgl v4.3.0 | ||
* unity-webgl v4.4.0 | ||
* Copyright (c) 2025 Mariner<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the Apache-2.0 License. |
/*! | ||
* unity-webgl v4.3.0 | ||
* unity-webgl v4.4.0 | ||
* Copyright (c) 2025 Mariner<mengqing723@gmail.com> | ||
@@ -4,0 +4,0 @@ * Released under the Apache-2.0 License. |
{ | ||
"name": "unity-webgl", | ||
"version": "4.3.0", | ||
"description": "Unity-Webgl provides an easy solution for embedding Unity WebGL builds in your webApp or Vue.js project, with two-way communication between your webApp and Unity application with advanced API's.", | ||
"version": "4.4.0", | ||
"description": "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.", | ||
"main": "dist/index.js", | ||
@@ -26,3 +26,4 @@ "module": "dist/index.mjs", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"global.d.ts" | ||
], | ||
@@ -42,4 +43,4 @@ "buildOptions": { | ||
"unity", | ||
"unity3d", | ||
"unity webgl", | ||
"unity3d webgl", | ||
"vue unity", | ||
@@ -46,0 +47,0 @@ "unity player", |
@@ -121,17 +121,21 @@ # unity-webgl | ||
| Property | Type | Description | Required | | ||
| ------------------------ | ------- | -------------------------------------------------------------------------------------------------- | -------- | | ||
| `loaderUrl` | string | Unity resource loader file | ✅ | | ||
| `dataUrl` | string | File containing resource data and scenes | ✅ | | ||
| `frameworkUrl` | string | File with runtime and plugin code | ✅ | | ||
| `codeUrl` | string | WebAssembly binary file with native code | ✅ | | ||
| `streamingAssetsUrl` | string | URL for streaming resources | Optional | | ||
| `memoryUrl` | string | URL for generated framework files | Optional | | ||
| `symbolsUrl` | string | URL for generated Unity code files | Optional | | ||
| `companyName` | string | Metadata: Company name | Optional | | ||
| `productName` | string | Metadata: Product name | Optional | | ||
| `productVersion` | string | Metadata: Product version | Optional | | ||
| `devicePixelRatio` | number | Canvas device pixel ratio. @see[devicePixelRatio][devicePixelRatio-url] | Optional | | ||
| `matchWebGLToCanvasSize` | boolean | Disable automatic WebGL canvas size sync. @see[matchWebGLToCanvasSize][matchWebGLToCanvasSize-url] | Optional | | ||
| `webglContextAttributes` | object | WebGL rendering context options. @see[WebGLRenderingContext][webglContextAttributes-url] | Optional | | ||
| Property | Type | Description | Required | | ||
| ---------------------------- | ----------------- | -------------------------------------------------------------------------------------------------- | -------- | | ||
| `loaderUrl` | string | Unity resource loader file | ✅ | | ||
| `dataUrl` | string | File containing resource data and scenes | ✅ | | ||
| `frameworkUrl` | string | File with runtime and plugin code | ✅ | | ||
| `codeUrl` | string | WebAssembly binary file with native code | ✅ | | ||
| `streamingAssetsUrl` | string | URL for streaming resources | Optional | | ||
| `memoryUrl` | string | URL for generated framework files | Optional | | ||
| `symbolsUrl` | string | URL for generated Unity code files | Optional | | ||
| `workerUrl` | string | URL for generated Unity web worker files | Optional | | ||
| `companyName` | string | Metadata: Company name | Optional | | ||
| `productName` | string | Metadata: Product name | Optional | | ||
| `productVersion` | string | Metadata: Product version | Optional | | ||
| `webglContextAttributes` | object | WebGL rendering context options. @see[WebGLRenderingContext][webglContextAttributes-url] | Optional | | ||
| `devicePixelRatio` | number | Canvas device pixel ratio. @see[devicePixelRatio][devicePixelRatio-url] | Optional | | ||
| `matchWebGLToCanvasSize` | boolean | Disable automatic WebGL canvas size sync. @see[matchWebGLToCanvasSize][matchWebGLToCanvasSize-url] | Optional | | ||
| `autoSyncPersistentDataPath` | boolean | Enables or disables auto synchronization of the persistent data path. | 可选 | | ||
| `disabledCanvasEvents` | string[] | Overwrites the default disabled canvas events. | 可选 | | ||
| `cacheControl` | `(url) => string` | The Cache Control API | 可选 | | ||
@@ -221,3 +225,3 @@ [devicePixelRatio-url]: https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | ||
#### `addUnityListener(name: string, listener: EventListener, options?: { once?: boolean }): this;` | ||
#### ⭐️ `addUnityListener(name: string, listener: EventListener, options?: { once?: boolean }): this;` | ||
@@ -243,3 +247,3 @@ Register a specific listener for Unity to call. | ||
### `window.dispatchUnityEvent(name: string, ...args: any[])` | ||
### ⭐️ `window.dispatchUnityEvent(name: string, ...args: any[])` | ||
@@ -246,0 +250,0 @@ The way to dispatch a registered listener on the Unity side. (Calling JS methods in unity) |
@@ -121,17 +121,21 @@ # unity-webgl | ||
| Property | Type | Description | Required | | ||
| ------------------------ | ------- | ------------------------------------------------------------------------------------- | -------- | | ||
| `loaderUrl` | string | Unity 资源加载器文件 | ✅ | | ||
| `dataUrl` | string | 包含资源数据和场景的文件 | ✅ | | ||
| `frameworkUrl` | string | 包含运行时和插件代码的文件 | ✅ | | ||
| `codeUrl` | string | 包含原生代码的 WebAssembly 二进制文件 | ✅ | | ||
| `streamingAssetsUrl` | string | 流媒体资源的 URL | 可选 | | ||
| `memoryUrl` | string | 生成的框架文件的 URL | 可选 | | ||
| `symbolsUrl` | string | 生成的 Unity 代码文件的 URL | 可选 | | ||
| `companyName` | string | 元数据:公司名称 | 可选 | | ||
| `productName` | string | 元数据:产品名称 | 可选 | | ||
| `productVersion` | string | 元数据:产品版本 | 可选 | | ||
| `devicePixelRatio` | number | 画布设备像素比率. @see[devicePixelRatio][devicePixelRatio-url] | 可选 | | ||
| `matchWebGLToCanvasSize` | boolean | 禁用 WebGL 画布大小自动同步. @see[matchWebGLToCanvasSize][matchWebGLToCanvasSize-url] | 可选 | | ||
| `webglContextAttributes` | object | WebGL 渲染上下文选项. @see[WebGLRenderingContext][webglContextAttributes-url] | 可选 | | ||
| Property | Type | Description | Required | | ||
| ---------------------------- | ----------------- | --------------------------------------------------------------------------------------- | -------- | | ||
| `loaderUrl` | string | Unity 资源加载器文件 | ✅ | | ||
| `dataUrl` | string | 包含资源数据和场景的文件 | ✅ | | ||
| `frameworkUrl` | string | 包含运行时和插件代码的文件 | ✅ | | ||
| `codeUrl` | string | 包含原生代码的 WebAssembly 二进制文件 | ✅ | | ||
| `streamingAssetsUrl` | string | 流媒体资源的 URL | 可选 | | ||
| `memoryUrl` | string | Unity生成的框架文件的 URL | 可选 | | ||
| `symbolsUrl` | string | Unity生成的代码文件 URL | 可选 | | ||
| `workerUrl` | string | Unity生成的web worker文件URL | 可选 | | ||
| `companyName` | string | 元数据 | 可选 | | ||
| `productName` | string | 元数据 | 可选 | | ||
| `productVersion` | string | 元数据 | 可选 | | ||
| `webglContextAttributes` | object | WebGL 渲染上下文选项. @see[WebGLRenderingContext][webglContextAttributes-url] | 可选 | | ||
| `devicePixelRatio` | number | canvas设备像素比率. @see[devicePixelRatio][devicePixelRatio-url] | 可选 | | ||
| `matchWebGLToCanvasSize` | boolean | 禁用 WebGL canvas大小自动同步. @see[matchWebGLToCanvasSize][matchWebGLToCanvasSize-url] | 可选 | | ||
| `autoSyncPersistentDataPath` | boolean | 启用/禁用持久数据自动同步 | 可选 | | ||
| `disabledCanvasEvents` | string[] | 禁用一些默认canvas事件 | 可选 | | ||
| `cacheControl` | `(url) => string` | 缓存控制 API | 可选 | | ||
@@ -148,5 +152,5 @@ [devicePixelRatio-url]: https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | ||
在指定画布上渲染 Unity WebGL 实例资源。 | ||
在指定canvas上渲染 Unity WebGL 实例资源。 | ||
- `canvas` : canvas画布元素 | ||
- `canvas` : canvas元素 | ||
@@ -179,7 +183,7 @@ ```javascript | ||
请求锁定 Unity 画布的指针。 | ||
请求锁定 Unity canvas的指针。 | ||
#### `takeScreenshot(dataType?: string, quality?: any): string | undefined;` | ||
对 Unity 画布进行屏幕截图并返回包含图像数据的数据 URL。 | ||
对 Unity canvas进行屏幕截图并返回包含图像数据的数据 URL。 | ||
@@ -223,5 +227,5 @@ - `dataType`: 图像数据的类型 | ||
#### `addUnityListener(name: string, listener: EventListener, options?: { once?: boolean }): this;` | ||
#### ⭐️ `addUnityListener(name: string, listener: EventListener, options?: { once?: boolean }): this;` | ||
注册特定监听器供 Unity 端调用。 | ||
注册监听器供 Unity 端调用。 | ||
@@ -239,3 +243,3 @@ ```javascript | ||
移除注册的监听器。 | ||
移除供Unity端注册的监听器。 | ||
@@ -246,5 +250,5 @@ ```javascript | ||
### `window.dispatchUnityEvent(name: string, ...args: any[])` | ||
### ⭐️ `window.dispatchUnityEvent(name: string, ...args: any[])` | ||
在 Unity 端派发注册的监听器的方式。(在 unity 中调用 JS 的方法) | ||
在 Unity 端触发注册的监听器的方式。(在 unity 中调用 JS 的方法) | ||
@@ -251,0 +255,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
114546
5.04%15
7.14%1437
7.96%347
1.17%