├── .github ├── banner_dark.png ├── banner_light.png └── workflows │ └── doc.yml ├── .gitignore ├── Bridge~ ├── .gitignore ├── package.json ├── pnpm-lock.yaml ├── src │ ├── UnityBridge.ts │ └── index.ts ├── tsconfig.json └── webpack.config.js ├── Documentation~ ├── .gitignore ├── api │ ├── .gitignore │ └── index.md ├── docfx.json └── toc.yml ├── LICENSE ├── LICENSE.meta ├── NOTICE ├── NOTICE.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── Plugins.meta ├── Plugins │ ├── .gitattributes │ ├── livekit-bridge.jslib │ ├── livekit-bridge.jslib.meta │ ├── livekit-client.jspre │ ├── livekit-client.jspre.meta │ ├── livekit-jsbridge.jspre │ └── livekit-jsbridge.jspre.meta ├── Scripts.meta ├── Scripts │ ├── Client.cs │ ├── Client.cs.meta │ ├── Events.cs │ ├── Events.cs.meta │ ├── Internal.meta │ ├── Internal │ │ ├── HTMLAudioElement.cs │ │ ├── HTMLAudioElement.cs.meta │ │ ├── HTMLElement.cs │ │ ├── HTMLElement.cs.meta │ │ ├── HTMLMediaElement.cs │ │ ├── HTMLMediaElement.cs.meta │ │ ├── HTMLVideoElement.cs │ │ ├── HTMLVideoElement.cs.meta │ │ ├── JSArray.cs │ │ ├── JSArray.cs.meta │ │ ├── JSBridge.cs │ │ ├── JSBridge.cs.meta │ │ ├── JSError.cs │ │ ├── JSError.cs.meta │ │ ├── JSEventEmitter.cs │ │ ├── JSEventEmitter.cs.meta │ │ ├── JSHandle.cs │ │ ├── JSHandle.cs.meta │ │ ├── JSMap.cs │ │ ├── JSMap.cs.meta │ │ ├── JSNative.cs │ │ ├── JSNative.cs.meta │ │ ├── JSObject.cs │ │ ├── JSObject.cs.meta │ │ ├── JSPromise.cs │ │ ├── JSPromise.cs.meta │ │ ├── JSRef.cs │ │ ├── JSRef.cs.meta │ │ ├── JSUint8Array.cs │ │ ├── JSUint8Array.cs.meta │ │ ├── Log.cs │ │ ├── Log.cs.meta │ │ ├── MediaStreamTrack.cs │ │ ├── MediaStreamTrack.cs.meta │ │ ├── Proto.cs │ │ ├── Proto.cs.meta │ │ ├── Utils.cs │ │ ├── Utils.cs.meta │ │ ├── WebRTC.cs │ │ └── WebRTC.cs.meta │ ├── Options.cs │ ├── Options.cs.meta │ ├── Room.meta │ └── Room │ │ ├── Errors.cs │ │ ├── Errors.cs.meta │ │ ├── Participant.meta │ │ ├── Participant │ │ ├── LocalParticipant.cs │ │ ├── LocalParticipant.cs.meta │ │ ├── Participant.cs │ │ ├── Participant.cs.meta │ │ ├── ParticipantTrackPermission.cs │ │ ├── ParticipantTrackPermission.cs.meta │ │ ├── RemoteParticipant.cs │ │ └── RemoteParticipant.cs.meta │ │ ├── Room.cs │ │ ├── Room.cs.meta │ │ ├── Track.meta │ │ └── Track │ │ ├── LocalAudioTrack.cs │ │ ├── LocalAudioTrack.cs.meta │ │ ├── LocalTrack.cs │ │ ├── LocalTrack.cs.meta │ │ ├── LocalTrackPublication.cs │ │ ├── LocalTrackPublication.cs.meta │ │ ├── LocalVideoTrack.cs │ │ ├── LocalVideoTrack.cs.meta │ │ ├── Options.cs │ │ ├── Options.cs.meta │ │ ├── RemoteAudioTrack.cs │ │ ├── RemoteAudioTrack.cs.meta │ │ ├── RemoteTrack.cs │ │ ├── RemoteTrack.cs.meta │ │ ├── RemoteTrackPublication.cs │ │ ├── RemoteTrackPublication.cs.meta │ │ ├── RemoteVideoTrack.cs │ │ ├── RemoteVideoTrack.cs.meta │ │ ├── TSInterop.meta │ │ ├── TSInterop │ │ ├── IAudioTrack.cs │ │ ├── IAudioTrack.cs.meta │ │ ├── ITrack.cs │ │ ├── ITrack.cs.meta │ │ ├── IVideoTrack.cs │ │ └── IVideoTrack.cs.meta │ │ ├── Track.cs │ │ ├── Track.cs.meta │ │ ├── TrackPublication.cs │ │ └── TrackPublication.cs.meta ├── livekit.unity.Runtime.asmdef └── livekit.unity.Runtime.asmdef.meta ├── Samples~ ├── ExampleRoom │ ├── CopyPaste.cs │ ├── CopyPaste.cs.meta │ ├── ExampleAssembly.asmdef │ ├── ExampleAssembly.asmdef.meta │ ├── ExampleRoom.cs │ ├── ExampleRoom.cs.meta │ ├── JoinMenu.cs │ ├── JoinMenu.cs.meta │ ├── JoinScene.unity │ ├── JoinScene.unity.meta │ ├── ParticipantView.prefab │ ├── ParticipantView.prefab.meta │ ├── RoomScene.unity │ ├── RoomScene.unity.meta │ ├── copy-paste.jslib │ ├── copy-paste.jslib.meta │ ├── livekit-logo.png │ └── livekit-logo.png.meta └── JSExample │ ├── .gitignore │ ├── JSExample.cs │ ├── JSExample.cs.meta │ ├── JSExample.unity │ ├── JSExample.unity.meta │ ├── JSPackage~ │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── webpack.config.js │ ├── README.md │ ├── WebGLTemplates.meta │ └── WebGLTemplates │ ├── LiveKitDemoJS.meta │ └── LiveKitDemoJS │ ├── .gitattributes │ ├── index.html │ ├── index.html.meta │ └── index.js.meta ├── TestProject~ ├── .DS_Store ├── .gitignore ├── Assets │ ├── Scenes.meta │ ├── Scenes │ │ ├── SampleScene.unity │ │ └── SampleScene.unity.meta │ ├── Tests.meta │ └── Tests │ │ ├── JSHandleTest.cs │ │ ├── JSHandleTest.cs.meta │ │ ├── LKTests.cs │ │ ├── LKTests.cs.meta │ │ ├── livekit.unity.RuntimeTests.asmdef │ │ └── livekit.unity.RuntimeTests.asmdef.meta ├── Packages │ ├── manifest.json │ └── packages-lock.json └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── MemorySettings.asset │ ├── NavMeshAreas.asset │ ├── PackageManagerSettings.asset │ ├── Packages │ └── com.unity.testtools.codecoverage │ │ └── Settings.json │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── RiderScriptEditorPersistedState.asset │ ├── SceneTemplateSettings.json │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ ├── VFXManager.asset │ ├── VersionControlSettings.asset │ ├── XRSettings.asset │ └── boot.config ├── package.json └── package.json.meta /.github/banner_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/.github/banner_dark.png -------------------------------------------------------------------------------- /.github/banner_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/.github/banner_light.png -------------------------------------------------------------------------------- /.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: Publish C# references 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: windows-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | 15 | - name: Install DocFX 16 | uses: crazy-max/ghaction-chocolatey@v1 17 | with: 18 | args: install docfx 19 | 20 | - name: Copy README.md 21 | run: cp README.md Documentation~/index.md 22 | 23 | - name: Build DocFX 24 | run: docfx Documentation~/docfx.json 25 | 26 | - name: Deploy 27 | uses: peaceiris/actions-gh-pages@v3 28 | with: 29 | github_token: ${{ secrets.GITHUB_TOKEN }} 30 | publish_branch: gh-pages 31 | publish_dir: Documentation~/_site -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/obj/ -------------------------------------------------------------------------------- /Bridge~/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ -------------------------------------------------------------------------------- /Bridge~/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@livekit/livekit-unity", 3 | "version": "1.5.1", 4 | "description": "LiveKit Unity Bridge for WebGL", 5 | "main": "./dist/index.js", 6 | "source": "./src/index.ts", 7 | "types": "./dist/index.d.ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+ssh://git@github.com/livekit/client-sdk-unity-web.git" 11 | }, 12 | "files": [ 13 | "dist/**/*", 14 | "src/**/*" 15 | ], 16 | "scripts": { 17 | "build": "npx tsc", 18 | "buildunity": "npx webpack" 19 | }, 20 | "author": "", 21 | "license": "Apache-2.0", 22 | "dependencies": { 23 | "livekit-client": "^2.5.0", 24 | "typed-emitter": "^2.1.0" 25 | }, 26 | "devDependencies": { 27 | "ts-loader": "^9.2.6", 28 | "typescript": "^4.5.5", 29 | "webpack": "^5.68.0", 30 | "webpack-cli": "^5.0.1" 31 | }, 32 | "bugs": { 33 | "url": "https://github.com/livekit/client-sdk-unity-web/issues" 34 | }, 35 | "homepage": "https://github.com/livekit/client-sdk-unity-web#readme" 36 | } 37 | -------------------------------------------------------------------------------- /Bridge~/src/UnityBridge.ts: -------------------------------------------------------------------------------- 1 | import { Room } from "livekit-client" 2 | import type TypedEmitter from 'typed-emitter'; 3 | import { EventEmitter } from 'events'; 4 | 5 | export class UnityBridge extends (EventEmitter as new () => TypedEmitter) { 6 | private _ready : boolean = false; 7 | 8 | private constructor(){ 9 | super(); 10 | 11 | this.once(UnityEvent.BridgeReady, () => { 12 | this._ready = true; 13 | }); 14 | } 15 | 16 | public get ready() : boolean { 17 | return this._ready; 18 | } 19 | 20 | public static get instance() : UnityBridge { 21 | // The UnityBridge is set on window to expose the instance to Unity 22 | var w = (window); 23 | return w.lkbridgeinst || (w.lkbridgeinst = new this()); 24 | } 25 | 26 | emit(event: E, ...args: Parameters): boolean { 27 | return super.emit(event, ...args); 28 | } 29 | }; 30 | 31 | export enum UnityEvent { 32 | /** 33 | * When the Bridge has been initialized. 34 | */ 35 | BridgeReady = 'bridgeReady', 36 | 37 | /** 38 | * When a Room has been created in C# 39 | * (This allows access to the room instance on the js side) 40 | */ 41 | RoomCreated = 'roomCreated', 42 | } 43 | 44 | export type UnityCallbacks = { 45 | bridgeReady: () => void, 46 | roomCreated: (room : Room) => void 47 | }; 48 | -------------------------------------------------------------------------------- /Bridge~/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './UnityBridge'; -------------------------------------------------------------------------------- /Bridge~/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "outDir": "dist", 6 | "declaration": true, 7 | "sourceMap": true, 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "noUnusedLocals": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "moduleResolution": "node" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Bridge~/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const TerserPlugin = require("terser-webpack-plugin"); 3 | 4 | module.exports = { 5 | entry: { 6 | 'livekit': { 7 | import: ['livekit-client'], 8 | filename: 'Runtime/Plugins/livekit-client.jspre' 9 | }, 10 | 11 | 'lkbridge': { 12 | import: './src/index.ts', 13 | filename: 'Runtime/Plugins/livekit-jsbridge.jspre', 14 | dependOn: 'livekit' 15 | }, 16 | }, 17 | mode: 'production', 18 | devtool: 'inline-source-map', 19 | target: ["web"], 20 | module: { 21 | rules: [ 22 | { 23 | test: /\.tsx?$/, 24 | use: 'ts-loader', 25 | exclude: /node_modules/, 26 | }, 27 | ], 28 | }, 29 | resolve: { 30 | extensions: ['.tsx', '.ts', '.js'], 31 | }, 32 | optimization: { 33 | minimize: true, 34 | minimizer: [ 35 | new TerserPlugin({ 36 | extractComments: false, 37 | test: /\.jspre(\?.*)?$/i, 38 | terserOptions: { 39 | keep_classnames: true, 40 | keep_fnames: true, 41 | }, 42 | }), 43 | ], 44 | }, 45 | output: { 46 | globalObject: 'this', 47 | filename: '[name]', 48 | path: path.resolve(__dirname, '../'), 49 | library: { 50 | name: '[name]', 51 | type: 'window', 52 | } 53 | }, 54 | }; -------------------------------------------------------------------------------- /Documentation~/.gitignore: -------------------------------------------------------------------------------- 1 | DROP/ 2 | TEMP/ 3 | packages/ 4 | bin/ 5 | _site 6 | -------------------------------------------------------------------------------- /Documentation~/api/.gitignore: -------------------------------------------------------------------------------- 1 | *.yml 2 | .manifest 3 | -------------------------------------------------------------------------------- /Documentation~/api/index.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/Documentation~/api/index.md -------------------------------------------------------------------------------- /Documentation~/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "src": "..", 7 | "files": [ 8 | "Runtime/**/*.cs" 9 | ] 10 | } 11 | ], 12 | "dest": "api", 13 | "disableDefaultFilter": false 14 | } 15 | ], 16 | "build": { 17 | "globalMetadata": { 18 | "_appTitle": "LiveKit Unity SDK", 19 | "_appFooter": "LiveKit Client SDK for Unity WebGL", 20 | "_enableSearch": true 21 | }, 22 | "sitemap": { 23 | "baseUrl": "https://livekit.github.io/client-sdk-unity-web" 24 | }, 25 | "xrefService": [ 26 | "https://xref.docs.microsoft.com/query?uid={uid}" 27 | ], 28 | "content": [ 29 | { 30 | "files": [ 31 | "api/**.yml", 32 | "api/index.md" 33 | ] 34 | }, 35 | { 36 | "files": [ 37 | "toc.yml", 38 | "*.md" 39 | ] 40 | } 41 | ], 42 | "overwrite": [ 43 | { 44 | "exclude": [ 45 | "obj/**", 46 | "_site/**" 47 | ] 48 | } 49 | ], 50 | "dest": "_site", 51 | "globalMetadataFiles": [], 52 | "fileMetadataFiles": [], 53 | "template": [ 54 | "default" 55 | ], 56 | "postProcessors": [], 57 | "markdownEngineName": "markdig", 58 | "noLangKeyword": false, 59 | "keepFileLink": false, 60 | "cleanupCacheHistory": false, 61 | "disableGitFeatures": false 62 | } 63 | } -------------------------------------------------------------------------------- /Documentation~/toc.yml: -------------------------------------------------------------------------------- 1 | - name: SDK References 2 | href: api/ 3 | homepage: api/index.md 4 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a4207737779b794ea573614e5e30c60 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2022 LiveKit, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /NOTICE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 359a83e9c8f4a4ebba84a1f6414a7709 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | The LiveKit icon, the name of the repository and some sample code in the background. 7 | 8 | 9 | 10 | 11 | # LiveKit Unity SDK 12 | 13 | 14 | Use this SDK to add realtime video, audio and data features to your Unity (WebGL) app. By connecting to LiveKit Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code. 15 | 16 | 17 | ## Docs 18 | Docs and guides at https://docs.livekit.io 19 | 20 | [SDK reference](https://livekit.github.io/client-sdk-unity-web/) 21 | 22 | ## Installation : 23 | Follow this [unity tutorial](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using the `https://github.com/livekit/client-sdk-unity-web.git` link. 24 | You can then directly import the samples into the package manager. 25 | 26 | If you want to write JavaScript code in your application (e.g. you want to use React for your UI), you can install our [TypeScript package](https://www.npmjs.com/package/@livekit/livekit-unity) via npm. 27 | To avoid confusion, the npm package and the Unity package will always have the same version number. 28 | 29 | ## Usage : 30 | There are two different ways to build an application using this package : 31 | 1. Write your application entirely in C# (e.g. [ExampleRoom](https://github.com/livekit/client-sdk-unity-web/tree/main/Samples~/ExampleRoom)) 32 | 2. Still use JS and be able to bridge the Room object by using our npm package. (e.g. [JSExample](https://github.com/livekit/client-sdk-unity-web/tree/main/Samples~/JSExample)) 33 | 34 | ### Debugging 35 | To display internal LiveKit logs, add LK DEBUG to define symbols 36 | 37 | ## Examples 38 | For a complete example, look at our [demo](https://github.com/livekit/client-unity-demo) 39 | ### Connecting to a room 40 | ```cs 41 | public class MyObject : MonoBehaviour 42 | { 43 | public Room Room; 44 | 45 | IEnumerator Start() 46 | { 47 | Room = new Room(); 48 | var c = Room.Connect("", ""); 49 | yield return c; 50 | 51 | if (!c.IsError) { 52 | // Connected 53 | } 54 | } 55 | } 56 | 57 | ``` 58 | 59 | ### Publishing video & audio 60 | 61 | ```cs 62 | yield return Room.LocalParticipant.EnableCameraAndMicrophone(); 63 | ``` 64 | 65 | ### Display a video on a RawImage 66 | ```cs 67 | RawImage image = GetComponent(); 68 | 69 | Room.TrackSubscribed += (track, publication, participant) => 70 | { 71 | if(track.Kind == TrackKind.Video) 72 | { 73 | var video = track.Attach() as HTMLVideoElement; 74 | video.VideoReceived += tex => 75 | { 76 | // VideoReceived is called every time the video resolution changes 77 | image.texture = tex; 78 | }; 79 | } 80 | }; 81 | ``` 82 | 83 | ### Sending/Receiving data 84 | ```cs 85 | Room.DataReceived += (data, participant, kind) => 86 | { 87 | Debug.Log("Received data : " + Encoding.ASCII.GetString(data)); 88 | }; 89 | 90 | yield return Room.LocalParticipant.PublishData(Encoding.ASCII.GetBytes("This is as test"), DataPacketKind.RELIABLE); 91 | ``` 92 | 93 | 94 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 |
LiveKit Ecosystem
LiveKit SDKsBrowser · iOS/macOS/visionOS · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL)
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
UI ComponentsReact · Android Compose · SwiftUI
Agents FrameworksPython · Node.js · Playground
ServicesLiveKit server · Egress · Ingress · SIP
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI
105 | 106 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50665db47b0fa7f41a1def35dbacb3a9 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ffd5237567347294e9fd7021ce07221f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f53c661cc519ec4e8be74e2c47f69d4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Plugins/.gitattributes: -------------------------------------------------------------------------------- 1 | livekit-client.jspre linguist-generated 2 | livekit-jsbridge.jspre linguist-generated -------------------------------------------------------------------------------- /Runtime/Plugins/livekit-bridge.jslib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd59fb1bc50594845a0b04f32b74b198 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | WebGL: WebGL 27 | second: 28 | enabled: 1 29 | settings: {} 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /Runtime/Plugins/livekit-client.jspre.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa7ad72fd84eda34e8b7a1bba1272acc 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | WebGL: WebGL 27 | second: 28 | enabled: 1 29 | settings: {} 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /Runtime/Plugins/livekit-jsbridge.jspre: -------------------------------------------------------------------------------- 1 | "use strict";(this.webpackChunk_livekit_livekit_unity=this.webpackChunk_livekit_livekit_unity||[]).push([[351],{7:e=>{var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function ReflectApply(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function NumberIsNaN(e){return e!=e};function EventEmitter(){EventEmitter.init.call(this)}e.exports=EventEmitter,e.exports.once=function once(e,t){return new Promise((function(n,r){function errorListener(n){e.removeListener(t,resolver),r(n)}function resolver(){"function"==typeof e.removeListener&&e.removeListener("error",errorListener),n([].slice.call(arguments))}eventTargetAgnosticAddListener(e,t,resolver,{once:!0}),"error"!==t&&function addErrorHandlerIfEventEmitter(e,t,n){"function"==typeof e.on&&eventTargetAgnosticAddListener(e,"error",t,n)}(e,errorListener,{once:!0})}))},EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var s=10;function checkListener(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function _getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,n,r){var i,s,o;if(checkListener(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=_getMaxListeners(e))>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}(u)}return e}function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=onceWrapper.bind(r);return i.listener=n,r.wrapFn=i,i}function _listeners(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function unwrapListeners(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var v=s[e];if(void 0===v)return!1;if("function"==typeof v)r(v,this,t);else{var a=v.length,c=arrayClone(v,a);for(n=0;n=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function spliceOne(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},EventEmitter.prototype.listeners=function listeners(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function rawListeners(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?t(this._events):[]}},483:(e,t,n)=>{n.r(t),n.d(t,{UnityBridge:()=>UnityBridge,UnityEvent:()=>r});var r,i=n(7);class UnityBridge extends i.EventEmitter{_ready=!1;constructor(){super(),this.once(r.BridgeReady,(()=>{this._ready=!0}))}get ready(){return this._ready}static get instance(){var e=window;return e.lkbridgeinst||(e.lkbridgeinst=new this)}emit(e,...t){return super.emit(e,...t)}}!function(e){e.BridgeReady="bridgeReady",e.RoomCreated="roomCreated"}(r||(r={}))}},e=>{var t,n=(t=483,e(e.s=t));window.lkbridge=n}]); -------------------------------------------------------------------------------- /Runtime/Plugins/livekit-jsbridge.jspre.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21c51a549f1ca9c429e658596cb23a65 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | WebGL: WebGL 27 | second: 28 | enabled: 1 29 | settings: {} 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /Runtime/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab2e4188d607bcc4caa9c750cbea6f7d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Scripts/Client.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace LiveKit 5 | { 6 | public class Client 7 | { 8 | public static void SetLogLevel(LogLevel level) 9 | { 10 | JSNative.PushString(Utils.ToEnumString(level)); 11 | JSNative.CallMethod(JSNative.LiveKit, "setLogLevel"); 12 | } 13 | 14 | public static JSPromise> CreateLocalTracks(CreateLocalTracksOptions? options = null) 15 | { 16 | if (options != null) 17 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 18 | 19 | return JSRef.Acquire>>(JSNative.CallMethod(JSNative.LiveKit, "createLocalTracks")); 20 | } 21 | 22 | public static JSPromise CreateLocalVideoTrack(VideoCaptureOptions? options = null) 23 | { 24 | if (options != null) 25 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 26 | 27 | return JSRef.Acquire>(JSNative.CallMethod(JSNative.LiveKit, "createLocalVideoTrack")); 28 | } 29 | 30 | public static JSPromise CreateLocalAudioTrack(AudioCaptureOptions? options = null) 31 | { 32 | if (options != null) 33 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 34 | 35 | return JSRef.Acquire>(JSNative.CallMethod(JSNative.LiveKit, "createLocalAudioTrack")); 36 | } 37 | 38 | public static JSPromise> CreateLocalScreenTracks(ScreenShareCaptureOptions? options = null) 39 | { 40 | if (options != null) 41 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 42 | 43 | return JSRef.Acquire>>(JSNative.CallMethod(JSNative.LiveKit, "createLocalScreenTracks")); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Client.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 495ba3ca1f664ae48bba0100bf14a87b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Events.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace LiveKit 6 | { 7 | [JsonConverter(typeof(StringEnumConverter))] 8 | public enum RoomEvent 9 | { 10 | [EnumMember(Value = "reconnecting")] 11 | Reconnecting, 12 | [EnumMember(Value = "reconnected")] 13 | Reconnected, 14 | [EnumMember(Value = "disconnected")] 15 | Disconnected, 16 | [EnumMember(Value = "stateChanged")] 17 | StateChanged, 18 | [EnumMember(Value = "mediaDevicesChanged")] 19 | MediaDevicesChanged, 20 | [EnumMember(Value = "participantConnected")] 21 | ParticipantConnected, 22 | [EnumMember(Value = "participantDisconnected")] 23 | ParticipantDisconnected, 24 | [EnumMember(Value = "trackPublished")] 25 | TrackPublished, 26 | [EnumMember(Value = "trackSubscribed")] 27 | TrackSubscribed, 28 | [EnumMember(Value = "trackSubscriptionFailed")] 29 | TrackSubscriptionFailed, 30 | [EnumMember(Value = "trackUnpublished")] 31 | TrackUnpublished, 32 | [EnumMember(Value = "trackUnsubscribed")] 33 | TrackUnsubscribed, 34 | [EnumMember(Value = "trackMuted")] 35 | TrackMuted, 36 | [EnumMember(Value = "trackUnmuted")] 37 | TrackUnmuted, 38 | [EnumMember(Value = "localTrackPublished")] 39 | LocalTrackPublished, 40 | [EnumMember(Value = "localTrackUnpublished")] 41 | LocalTrackUnpublished, 42 | [EnumMember(Value = "activeSpeakersChanged")] 43 | ActiveSpeakersChanged, 44 | [EnumMember(Value = "participantMetadataChanged")] 45 | ParticipantMetadataChanged, 46 | [EnumMember(Value = "roomMetadataChanged")] 47 | RoomMetadataChanged, 48 | [EnumMember(Value = "dataReceived")] 49 | DataReceived, 50 | [EnumMember(Value = "connectionQualityChanged")] 51 | ConnectionQualityChanged, 52 | [EnumMember(Value = "trackStreamStateChanged")] 53 | TrackStreamStateChanged, 54 | [EnumMember(Value = "trackSubscriptionPermissionChanged")] 55 | TrackSubscriptionPermissionChanged, 56 | [EnumMember(Value = "audioPlaybackChanged")] 57 | AudioPlaybackStatusChanged, 58 | [EnumMember(Value = "mediaDevicesError")] 59 | MediaDevicesError, 60 | [EnumMember(Value = "participantAttributesChanged")] 61 | ParticipantAttributesChanged, 62 | } 63 | 64 | [JsonConverter(typeof(StringEnumConverter))] 65 | public enum ParticipantEvent 66 | { 67 | [EnumMember(Value = "trackPublished")] 68 | TrackPublished, 69 | [EnumMember(Value = "trackSubscribed")] 70 | TrackSubscribed, 71 | [EnumMember(Value = "trackSubscriptionFailed")] 72 | TrackSubscriptionFailed, 73 | [EnumMember(Value = "trackUnpublished")] 74 | TrackUnpublished, 75 | [EnumMember(Value = "trackUnsubscribed")] 76 | TrackUnsubscribed, 77 | [EnumMember(Value = "trackMuted")] 78 | TrackMuted, 79 | [EnumMember(Value = "trackUnmuted")] 80 | TrackUnmuted, 81 | [EnumMember(Value = "localTrackPublished")] 82 | LocalTrackPublished, 83 | [EnumMember(Value = "localTrackUnpublished")] 84 | LocalTrackUnpublished, 85 | [EnumMember(Value = "participantMetadataChanged")] 86 | ParticipantMetadataChanged, 87 | [EnumMember(Value = "dataReceived")] 88 | DataReceived, 89 | [EnumMember(Value = "isSpeakingChanged")] 90 | IsSpeakingChanged, 91 | [EnumMember(Value = "connectionQualityChanged")] 92 | ConnectionQualityChanged, 93 | [EnumMember(Value = "trackStreamStateChanged")] 94 | TrackStreamStateChanged, 95 | [EnumMember(Value = "trackSubscriptionPermissionChanged")] 96 | TrackSubscriptionPermissionChanged, 97 | } 98 | 99 | [JsonConverter(typeof(StringEnumConverter))] 100 | public enum TrackEvent 101 | { 102 | [EnumMember(Value = "message")] 103 | Message, 104 | [EnumMember(Value = "muted")] 105 | Muted, 106 | [EnumMember(Value = "unmuted")] 107 | Unmuted, 108 | [EnumMember(Value = "ended")] 109 | Ended, 110 | 111 | // Internals 112 | [EnumMember(Value = "elementAttached")] 113 | ElementAttached, 114 | [EnumMember(Value = "elementDetached")] 115 | ElementDetached 116 | } 117 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Events.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9744491aa05b0a443ad3a763ea8ea645 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2542957518b1943408e52203602b8c59 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLAudioElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | 6 | public class HTMLAudioElement : HTMLMediaElement 7 | { 8 | [Preserve] 9 | internal HTMLAudioElement(JSHandle handle) : base(handle) 10 | { 11 | 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLAudioElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c075566c39bfa3b40912975d56322422 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | public abstract class HTMLElement : JSObject 6 | { 7 | [Preserve] 8 | internal HTMLElement(JSHandle handle) : base(handle) 9 | { 10 | 11 | } 12 | 13 | internal void AddEventListener(string e, JSNative.JSDelegate callback, JSHandle identifier = null) 14 | { 15 | if (identifier == null) 16 | identifier = NativeHandle; 17 | 18 | JSNative.PushString(e); 19 | JSNative.PushFunction(identifier, callback, $"HTMLElement - EventListener: {e}"); 20 | JSNative.CallMethod(NativeHandle, "addEventListener"); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 114a3cc9d3284a447a9515c32153cd22 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLMediaElement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | public abstract class HTMLMediaElement : HTMLElement 7 | { 8 | public float Volume 9 | { 10 | get 11 | { 12 | JSNative.PushString("volume"); 13 | return (float) JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 14 | } 15 | set 16 | { 17 | JSNative.PushString("volume"); 18 | JSNative.PushNumber(value); 19 | JSNative.SetProperty(NativeHandle); 20 | } 21 | } 22 | 23 | [Preserve] 24 | internal HTMLMediaElement(JSHandle handle) : base(handle) 25 | { 26 | 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLMediaElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff42241d60f635045b86b71e2a353bee 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLVideoElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AOT; 3 | using UnityEngine; 4 | using UnityEngine.Scripting; 5 | using Object = UnityEngine.Object; 6 | 7 | namespace LiveKit 8 | { 9 | public class HTMLVideoElement : HTMLMediaElement 10 | { 11 | public int VideoWidth 12 | { 13 | get 14 | { 15 | JSNative.PushString("videoWidth"); 16 | return (int)JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 17 | } 18 | } 19 | 20 | public int VideoHeight 21 | { 22 | get 23 | { 24 | JSNative.PushString("videoHeight"); 25 | return (int)JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 26 | } 27 | } 28 | 29 | [MonoPInvokeCallback(typeof(JSNative.JSDelegate))] 30 | private static void ResizeEvent(IntPtr ptr) 31 | { 32 | try 33 | { 34 | var handle = new JSHandle(ptr, true); 35 | if (!JSNative.IsObject(handle)) 36 | return; 37 | 38 | var el = Acquire(handle); 39 | Log.Debug($"Received HTMLVideoElement.Resize {el.VideoWidth}x{el.VideoHeight}"); 40 | 41 | if (el.VideoWidth == 0 || el.VideoHeight == 0) 42 | Debug.LogError($"HTMLVideoElement.Resize - Wrong size: {el.VideoWidth}*{el.VideoHeight}"); 43 | 44 | el.SetupTexture(); 45 | el.VideoReceived?.Invoke(el.Texture); 46 | } 47 | catch (Exception e) 48 | { 49 | Log.Error($"Error happened on HTMLVideoElement.VideoReceived ( Is your listeners working correctly ? ): {Environment.NewLine} {e.Message}"); 50 | } 51 | } 52 | 53 | public delegate void VideoReceivedDelegate(Texture2D tex); 54 | public event VideoReceivedDelegate VideoReceived; 55 | 56 | public Texture2D Texture { get; private set; } 57 | private readonly int m_TextureId; 58 | 59 | [Preserve] 60 | internal HTMLVideoElement(JSHandle handle) : base(handle) 61 | { 62 | m_TextureId = JSNative.NewTexture(); 63 | SetupTexture(); 64 | JSNative.AttachVideo(NativeHandle, m_TextureId); 65 | AddEventListener("resize", ResizeEvent); 66 | } 67 | 68 | protected override void Dispose(bool disposing) 69 | { 70 | base.Dispose(disposing); 71 | Object.Destroy(Texture); 72 | JSNative.DestroyTexture(m_TextureId); 73 | } 74 | 75 | void SetupTexture() 76 | { 77 | if (Texture != null) 78 | Object.Destroy(Texture); 79 | 80 | var width = VideoWidth > 0 ? VideoWidth : 1; 81 | var height = VideoHeight > 0 ? VideoHeight : 1; 82 | Texture = Texture2D.CreateExternalTexture(width, height, TextureFormat.RGBA32, false, true, (IntPtr)m_TextureId); 83 | } 84 | } 85 | }; 86 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/HTMLVideoElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a0e7809f87ef244aaaafcc564d78636 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using Newtonsoft.Json; 5 | using UnityEngine; 6 | using UnityEngine.Scripting; 7 | 8 | namespace LiveKit 9 | { 10 | public class JSArray : JSObject, IList 11 | { 12 | private object m_Lock = new object(); 13 | 14 | [Preserve] 15 | internal JSArray(JSHandle handle) : base(handle) 16 | { 17 | 18 | } 19 | 20 | public JSArray() 21 | { 22 | JSNative.NewInstance(JSNative.Window, NativeHandle, "Array"); 23 | } 24 | 25 | public JSArray(IEnumerable f) : this() 26 | { 27 | foreach(var i in f) 28 | Add(i); 29 | } 30 | 31 | public bool IsFixedSize => false; 32 | 33 | public bool IsReadOnly => false; 34 | 35 | public int Count { 36 | get 37 | { 38 | JSNative.PushString("length"); 39 | return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 40 | } 41 | } 42 | 43 | public bool IsSynchronized => false; 44 | 45 | public object SyncRoot => m_Lock; 46 | 47 | public T this[int index] 48 | { 49 | get 50 | { 51 | if(index >= Count) 52 | throw new IndexOutOfRangeException(); 53 | 54 | JSNative.PushNumber(index); 55 | var ptr = JSNative.GetProperty(NativeHandle); 56 | 57 | var type = typeof(T); 58 | if (JSNative.IsPrimitive(type)) 59 | return (T) JSNative.GetPrimitive(ptr); 60 | 61 | if (type.IsValueType) 62 | return JSNative.GetStruct(ptr); 63 | 64 | return (T)(object) Acquire(ptr); 65 | } 66 | set 67 | { 68 | JSNative.PushNumber(index); 69 | PushValue(value); 70 | JSNative.SetProperty(NativeHandle); 71 | } 72 | } 73 | 74 | public int IndexOf(T item) 75 | { 76 | PushValue(item); 77 | return (int) JSNative.GetNumber(JSNative.CallMethod(NativeHandle, "indexOf")); 78 | } 79 | 80 | public void Insert(int index, T item) 81 | { 82 | JSNative.PushNumber(index); 83 | JSNative.PushNumber(0); 84 | PushValue(item); 85 | JSNative.CallMethod(NativeHandle, "push"); 86 | } 87 | 88 | public void RemoveAt(int index) 89 | { 90 | JSNative.PushNumber(index); 91 | JSNative.PushNumber(1); 92 | JSNative.CallMethod(NativeHandle, "splice"); 93 | } 94 | 95 | public void Add(T obj) 96 | { 97 | PushValue(obj); 98 | JSNative.CallMethod(NativeHandle, "push"); 99 | } 100 | 101 | public void Clear() 102 | { 103 | JSNative.PushString("length"); 104 | JSNative.PushNumber(0); 105 | JSNative.SetProperty(NativeHandle); 106 | } 107 | 108 | public bool Contains(T item) 109 | { 110 | return IndexOf(item) > -1; 111 | } 112 | 113 | public void CopyTo(T[] array, int arrayIndex) 114 | { 115 | for(var i = 0; i < Count; i++) 116 | array[arrayIndex++] = this[i]; 117 | } 118 | 119 | public bool Remove(T item) 120 | { 121 | var i = IndexOf(item); 122 | if(i > -1) 123 | { 124 | RemoveAt(i); 125 | return true; 126 | } 127 | 128 | return false; 129 | } 130 | 131 | public IEnumerator GetEnumerator() 132 | { 133 | for(var i = 0; i < Count; i++) 134 | yield return this[i]; 135 | } 136 | 137 | IEnumerator IEnumerable.GetEnumerator() 138 | { 139 | return GetEnumerator(); 140 | } 141 | 142 | private void PushValue(T value) 143 | { 144 | var type = typeof(T); 145 | if (JSNative.IsPrimitive(type)) 146 | JSNative.PushPrimitive(value); 147 | else if(type.IsValueType) 148 | JSNative.PushStruct(JsonConvert.SerializeObject(value, JSNative.JsonSettings)); 149 | else 150 | JSNative.PushObject((value as JSRef).NativeHandle); 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a071f13e5ca1ad14a8b53372062218ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSBridge.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System.Runtime.Serialization; 4 | 5 | namespace LiveKit 6 | { 7 | [JsonConverter(typeof(StringEnumConverter))] 8 | internal enum JSUnityEvent 9 | { 10 | [EnumMember(Value = "bridgeReady")] 11 | BridgeReady, 12 | [EnumMember(Value = "roomCreated")] 13 | RoomCreated, 14 | } 15 | 16 | internal class JSBridge 17 | { 18 | private static JSHandle JSUnityBridge; 19 | 20 | static JSBridge() 21 | { 22 | #if !UNITY_EDITOR && UNITY_WEBGL 23 | JSNative.PushString("UnityBridge"); 24 | var ptr = JSNative.GetProperty(JSNative.BridgeInterface); 25 | 26 | JSNative.PushString("instance"); 27 | JSUnityBridge = JSNative.GetProperty(ptr); 28 | #endif 29 | } 30 | 31 | internal static void SendReady() 32 | { 33 | JSNative.PushString(Utils.ToEnumString(JSUnityEvent.BridgeReady)); 34 | JSNative.CallMethod(JSUnityBridge, "emit"); 35 | } 36 | 37 | public static void SendRoomCreated(Room room) 38 | { 39 | JSNative.PushString(Utils.ToEnumString(JSUnityEvent.RoomCreated)); 40 | JSNative.PushObject(room.NativeHandle); 41 | JSNative.CallMethod(JSUnityBridge, "emit"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSBridge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fcef70aa9e16054b9f5cc801339961b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | public class JSError : JSObject 7 | { 8 | public string Name 9 | { 10 | get 11 | { 12 | JSNative.PushString("name"); 13 | return JSNative.GetString(JSNative.GetProperty(NativeHandle)); 14 | } 15 | } 16 | 17 | public string Message 18 | { 19 | get 20 | { 21 | JSNative.PushString("message"); 22 | return JSNative.GetString(JSNative.GetProperty(NativeHandle)); 23 | } 24 | } 25 | 26 | 27 | [Preserve] 28 | internal JSError(JSHandle handle) : base(handle) 29 | { 30 | 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSError.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee7101e92097fb741a6340875d8c08cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSEventEmitter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine.Scripting; 4 | 5 | namespace LiveKit 6 | { 7 | public class JSEventEmitter : JSObject 8 | { 9 | internal class EventWrapper : JSObject 10 | { 11 | public T Event; 12 | public JSRef FncRef; 13 | } 14 | 15 | internal readonly Dictionary Events = new Dictionary(); 16 | 17 | [Preserve] 18 | internal JSEventEmitter(JSHandle handle) : base(handle) 19 | { 20 | SetKeepAlive(NativeHandle, true); 21 | } 22 | 23 | internal JSEventEmitter() 24 | { 25 | SetKeepAlive(NativeHandle, true); 26 | } 27 | 28 | protected override void Dispose(bool disposing) 29 | { 30 | base.Dispose(disposing); 31 | 32 | // Clear events 33 | foreach (var k in Events.Keys.ToArray()) 34 | RemoveListener(k); 35 | 36 | SetKeepAlive(NativeHandle, false); 37 | } 38 | 39 | // Similar to "on" but we only accepts one listener (No need for multiple in internal use) 40 | internal void SetListener(T eventt, JSNative.JSDelegate fnc) 41 | { 42 | var wrapper = new EventWrapper 43 | { 44 | Event = eventt, 45 | FncRef = new JSRef() 46 | }; 47 | 48 | SetKeepAlive(wrapper.FncRef, true); 49 | 50 | Events.Add(eventt, wrapper); 51 | 52 | JSNative.PushFunction(wrapper.NativeHandle, fnc, $"JSEventEmitter - Listener: {Utils.ToEnumString(eventt)}"); 53 | JSNative.SetRef(wrapper.FncRef.NativeHandle); 54 | 55 | JSNative.PushString(Utils.ToEnumString(eventt)); 56 | JSNative.PushObject(wrapper.FncRef.NativeHandle); 57 | JSNative.CallMethod(NativeHandle, "on"); 58 | } 59 | 60 | internal void RemoveListener(T eventt) 61 | { 62 | if (!Events.TryGetValue(eventt, out var wrapper)) 63 | return; 64 | 65 | JSNative.PushString(Utils.ToEnumString(eventt)); 66 | JSNative.PushObject(wrapper.FncRef.NativeHandle); 67 | JSNative.CallMethod(NativeHandle, "removeListener"); 68 | 69 | SetKeepAlive(wrapper.FncRef, false); 70 | Events.Remove(eventt); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSEventEmitter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14fcbd9f4925456d816740d78eb9af28 3 | timeCreated: 1648759842 -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Win32.SafeHandles; 3 | 4 | namespace LiveKit 5 | { 6 | public class JSHandle : SafeHandleZeroOrMinusOneIsInvalid 7 | { 8 | private JSHandle() : base(true) 9 | { 10 | 11 | } 12 | 13 | internal JSHandle(IntPtr ptr, bool ownsHandle) : base(ownsHandle) 14 | { 15 | SetHandle(ptr); 16 | } 17 | 18 | protected override bool ReleaseHandle() 19 | { 20 | return JSNative.RemRef(handle); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89c4b041b0d04b7d861eca2af61f1345 3 | timeCreated: 1647909061 -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using Newtonsoft.Json; 5 | using UnityEngine.Scripting; 6 | 7 | namespace LiveKit 8 | { 9 | public class JSMap : JSObject, IDictionary 10 | { 11 | public ICollection Keys 12 | { 13 | get 14 | { 15 | var keys = JSNative.CallMethod(NativeHandle, "keys"); 16 | 17 | JSNative.PushString("Array"); 18 | var array = JSNative.GetProperty(JSNative.Window); 19 | 20 | JSNative.PushObject(keys); 21 | return Acquire>(JSNative.CallMethod(array, "from")); 22 | } 23 | } 24 | 25 | public ICollection Values 26 | { 27 | get 28 | { 29 | var values = JSNative.CallMethod(NativeHandle, "values"); 30 | 31 | JSNative.PushString("Array"); 32 | var array = JSNative.GetProperty(JSNative.Window); 33 | 34 | JSNative.PushObject(values); 35 | return Acquire>(JSNative.CallMethod(array, "from")); 36 | } 37 | } 38 | 39 | public int Count 40 | { 41 | get 42 | { 43 | JSNative.PushString("size"); 44 | return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 45 | } 46 | } 47 | 48 | public bool IsReadOnly => false; 49 | 50 | public TValue this[TKey key] 51 | { 52 | get 53 | { 54 | if (!ContainsKey(key)) 55 | throw new KeyNotFoundException(); 56 | 57 | PushKey(key); 58 | var ptr = JSNative.CallMethod(NativeHandle, "get"); 59 | var type = typeof(TValue); 60 | if(JSNative.IsPrimitive(type)) 61 | return (TValue) JSNative.GetPrimitive(ptr); 62 | 63 | if (type.IsValueType) 64 | return JSNative.GetStruct(ptr); 65 | 66 | return (TValue)(object) Acquire(ptr); 67 | } 68 | set 69 | { 70 | PushKey(key); 71 | PushValue(value); 72 | JSNative.CallMethod(NativeHandle, "set"); 73 | } 74 | } 75 | 76 | public JSMap() 77 | { 78 | JSNative.NewInstance(JSNative.Window, NativeHandle, "Map"); 79 | } 80 | 81 | [Preserve] 82 | internal JSMap(JSHandle handle) : base(handle) 83 | { 84 | 85 | } 86 | 87 | public void Add(TKey key, TValue value) 88 | { 89 | if(ContainsKey(key)) 90 | throw new ArgumentException("Key already exits"); 91 | 92 | this[key] = value; 93 | } 94 | 95 | public bool ContainsKey(TKey key) 96 | { 97 | PushKey(key); 98 | return JSNative.GetBoolean(JSNative.CallMethod(NativeHandle, "has")); 99 | } 100 | 101 | public bool Remove(TKey key) 102 | { 103 | PushKey(key); 104 | return JSNative.GetBoolean(JSNative.CallMethod(NativeHandle, "delete")); 105 | } 106 | 107 | public bool TryGetValue(TKey key, out TValue value) 108 | { 109 | if (!ContainsKey(key)) 110 | { 111 | value = default(TValue); 112 | return false; 113 | } 114 | 115 | value = this[key]; 116 | return true; 117 | } 118 | 119 | public void Add(KeyValuePair item) 120 | { 121 | Add(item.Key, item.Value); 122 | } 123 | 124 | public void Clear() 125 | { 126 | JSNative.CallMethod(NativeHandle, "clear"); 127 | } 128 | 129 | public bool Contains(KeyValuePair item) 130 | { 131 | if(TryGetValue(item.Key, out var cref)) 132 | return cref.Equals(item.Value); 133 | 134 | return false; 135 | } 136 | 137 | public void CopyTo(KeyValuePair[] array, int arrayIndex) 138 | { 139 | foreach (var p in this) 140 | array[arrayIndex++] = p; 141 | } 142 | 143 | public bool Remove(KeyValuePair item) 144 | { 145 | if (TryGetValue(item.Key, out TValue v) && item.Value.Equals(v)) 146 | return Remove(item.Key); 147 | 148 | return false; 149 | } 150 | 151 | public IEnumerator> GetEnumerator() 152 | { 153 | foreach(var k in Keys) 154 | yield return new KeyValuePair(k, this[k]); 155 | } 156 | 157 | IEnumerator IEnumerable.GetEnumerator() 158 | { 159 | return GetEnumerator(); 160 | } 161 | 162 | private void PushKey(TKey key) 163 | { 164 | var type = typeof(TKey); 165 | if (JSNative.IsPrimitive(type)) 166 | JSNative.PushPrimitive(key); 167 | else if(type.IsValueType) 168 | JSNative.PushStruct(JsonConvert.SerializeObject(key, JSNative.JsonSettings)); 169 | else 170 | JSNative.PushObject((key as JSRef).NativeHandle); 171 | } 172 | 173 | private void PushValue(TValue value) 174 | { 175 | var type = typeof(TValue); 176 | if (JSNative.IsPrimitive(type)) 177 | JSNative.PushPrimitive(value); 178 | else if(type.IsValueType) 179 | JSNative.PushStruct(JsonConvert.SerializeObject(value, JSNative.JsonSettings)); 180 | else 181 | JSNative.PushObject((value as JSRef).NativeHandle); 182 | } 183 | } 184 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSMap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd071237627fbdf4e819beb9d403ecb7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSNative.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.ConstrainedExecution; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Converters; 7 | using System.Runtime.Serialization; 8 | using System.Security; 9 | using Newtonsoft.Json.Utilities; 10 | using UnityEngine; 11 | 12 | [assembly: InternalsVisibleTo("LiveKit.BridgeTests")] 13 | namespace LiveKit 14 | { 15 | internal static class JSNative 16 | { 17 | // JSHandle can't be marshalled in a delegate 18 | // JSHandle must be created with ptr when the callback is called 19 | public delegate void JSDelegate(IntPtr ptr); 20 | 21 | public static JsonSerializerSettings JsonSettings = new JsonSerializerSettings() 22 | { 23 | Formatting = Formatting.None, 24 | NullValueHandling = NullValueHandling.Ignore, 25 | }; 26 | 27 | internal static JSHandle LiveKit { get; private set; } 28 | internal static JSHandle BridgeInterface { get; private set; } // TypeScript interface 29 | internal static JSHandle Window { get; private set; } 30 | internal static JSHandle BridgeData { get; private set; } 31 | 32 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] 33 | private static void InitJSNative() 34 | { 35 | AotHelper.EnsureType(); 36 | #if !UNITY_EDITOR && UNITY_WEBGL 37 | 38 | #if LK_DEBUG 39 | InitLiveKit(true); 40 | #else 41 | InitLiveKit(false); 42 | #endif 43 | 44 | Window = RetrieveWindowObject(); 45 | BridgeData = RetrieveBridgeObject(); 46 | 47 | PushString("livekit"); 48 | LiveKit = GetProperty(Window); 49 | 50 | PushString("lkbridge"); 51 | BridgeInterface = GetProperty(Window); 52 | 53 | #if LK_DEBUG 54 | Client.SetLogLevel(LogLevel.Debug); 55 | #endif 56 | 57 | JSBridge.SendReady(); 58 | #endif 59 | } 60 | 61 | [DllImport("__Internal")] 62 | internal static extern void InitLiveKit(bool debug); 63 | 64 | [DllImport("__Internal")] 65 | internal static extern JSHandle NewRef(); 66 | 67 | [DllImport("__Internal")] 68 | internal static extern void AddRef(JSHandle ptr); 69 | 70 | [DllImport("__Internal"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] 71 | internal static extern bool RemRef(IntPtr ptr); 72 | 73 | [DllImport("__Internal")] 74 | internal static extern void SetRef(JSHandle ptr); 75 | 76 | [DllImport("__Internal")] 77 | internal static extern JSHandle GetProperty(JSHandle ptr); 78 | 79 | [DllImport("__Internal")] 80 | internal static extern void SetProperty(JSHandle ptr); 81 | 82 | [DllImport("__Internal")] 83 | internal static extern void PushNull(); 84 | 85 | [DllImport("__Internal")] 86 | internal static extern void PushUndefined(); 87 | 88 | [DllImport("__Internal")] 89 | internal static extern void PushNumber(double nb); 90 | 91 | [DllImport("__Internal")] 92 | internal static extern void PushBoolean(bool b); 93 | 94 | [DllImport("__Internal")] 95 | internal static extern void PushString(string str); 96 | 97 | [DllImport("__Internal")] 98 | internal static extern void PushStruct(string json); 99 | 100 | [DllImport("__Internal")] 101 | internal static extern void PushData(byte[] data, int offset, int size); 102 | 103 | [DllImport("__Internal")] 104 | internal static extern void PushObject(JSHandle ptr); 105 | 106 | [DllImport("__Internal")] 107 | internal static extern void PushFunction(JSHandle ptr, JSDelegate action, string debugLabel); 108 | 109 | [DllImport("__Internal")] 110 | internal static extern JSHandle CallMethod(JSHandle ptr, string fnc); 111 | 112 | [DllImport("__Internal")] 113 | internal static extern void NewInstance(JSHandle ptr, JSHandle toPtr, string clazz); 114 | 115 | [DllImport("__Internal")] 116 | internal static extern JSHandle ShiftStack(); 117 | 118 | [DllImport("__Internal")] 119 | internal static extern JSHandle GetFunctionInstance(); 120 | 121 | [DllImport("__Internal")] 122 | internal static extern bool IsString(JSHandle ptr); 123 | 124 | [DllImport("__Internal")] 125 | internal static extern bool IsNull(JSHandle ptr); 126 | 127 | [DllImport("__Internal")] 128 | internal static extern bool IsUndefined(JSHandle ptr); 129 | 130 | [DllImport("__Internal")] 131 | internal static extern bool IsObject(JSHandle ptr); 132 | 133 | [DllImport("__Internal")] 134 | internal static extern bool IsNumber(JSHandle ptr); 135 | 136 | [DllImport("__Internal")] 137 | internal static extern bool IsBoolean(JSHandle ptr); 138 | 139 | [DllImport("__Internal")] 140 | internal static extern string GetString(JSHandle ptr); 141 | 142 | [DllImport("__Internal")] 143 | internal static extern double GetNumber(JSHandle ptr); 144 | 145 | [DllImport("__Internal")] 146 | internal static extern bool GetBoolean(JSHandle ptr); 147 | 148 | [DllImport("__Internal")] 149 | internal static extern bool CopyData(JSHandle ptr, [Out] byte[] data, int offset, int count); 150 | 151 | [DllImport("__Internal")] 152 | internal static extern JSHandle RetrieveBridgeObject(); 153 | 154 | [DllImport("__Internal")] 155 | internal static extern JSHandle RetrieveWindowObject(); 156 | 157 | [DllImport("__Internal")] 158 | internal static extern int NewTexture(); 159 | 160 | [DllImport("__Internal")] 161 | internal static extern void DestroyTexture(int id); 162 | 163 | [DllImport("__Internal")] 164 | internal static extern void AttachVideo(JSHandle video, int texId); 165 | 166 | internal static T GetStruct(JSHandle ptr) 167 | { 168 | PushString("JSON"); 169 | var json = GetProperty(Window); 170 | 171 | PushObject(ptr); 172 | var strifyPtr = CallMethod(json, "stringify"); 173 | 174 | if(!IsString(strifyPtr)) 175 | throw new Exception($"Failed to bridge {typeof(T)}"); 176 | 177 | return JsonConvert.DeserializeObject(GetString(strifyPtr)); 178 | } 179 | 180 | internal static void PushPrimitive(object obj) 181 | { 182 | if (obj is string str) 183 | PushString(str); 184 | else if (obj is bool b) 185 | PushBoolean(b); 186 | else if (obj == null) 187 | PushNull(); 188 | else if (Utils.IsNumber(obj.GetType())) 189 | PushNumber((double) obj); 190 | else 191 | throw new ArgumentException("Unsupported type"); 192 | } 193 | 194 | internal static object GetPrimitive(JSHandle ptr) 195 | { 196 | if (IsString(ptr)) 197 | return GetString(ptr); 198 | if (IsNumber(ptr)) 199 | return GetNumber(ptr); 200 | if (IsBoolean(ptr)) 201 | return GetBoolean(ptr); 202 | if (IsNull(ptr) || IsUndefined(ptr)) 203 | return null; 204 | 205 | throw new ArgumentException("Unsupported type"); 206 | } 207 | 208 | internal static bool IsPrimitive(Type type) 209 | { 210 | var tc = Type.GetTypeCode(type); 211 | return tc == TypeCode.String || tc == TypeCode.Boolean || Utils.IsNumber(type); 212 | } 213 | } 214 | 215 | 216 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSNative.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78d8d435ed187f64aa0061e7f9a021c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSObject.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | /* 7 | * JSObject ensures that we are using a non-null reference 8 | */ 9 | public class JSObject : JSRef 10 | { 11 | [Preserve] 12 | internal JSObject(JSHandle handle) : base(handle) 13 | { 14 | if (JSNative.IsUndefined(handle) || JSNative.IsNull(handle)) 15 | Debug.LogError($"An object reference cannot be null, {GetType()}"); 16 | } 17 | 18 | internal JSObject() 19 | { 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da6013018d345894eb30a3afeaf2496b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSPromise.cs: -------------------------------------------------------------------------------- 1 | using AOT; 2 | using System; 3 | using System.Collections; 4 | using UnityEngine.Scripting; 5 | 6 | namespace LiveKit 7 | { 8 | public class JSPromise : JSObject, IEnumerator 9 | { 10 | [MonoPInvokeCallback(typeof(JSNative.JSDelegate))] 11 | private static void PromiseResolve(IntPtr id) 12 | { 13 | try 14 | { 15 | var handle = new JSHandle(id, true); 16 | if (!JSNative.IsObject(handle)) 17 | return; // The promise can be garbage collected before completed (When ignoring Promise) 18 | 19 | var promise = Acquire(handle); 20 | promise.OnResolve(); 21 | promise.IsDone = true; 22 | } 23 | catch (Exception e) 24 | { 25 | Log.Error($"Error happened on JSPromise.PromiseResolve: {Environment.NewLine} {e.Message}"); 26 | } 27 | } 28 | 29 | [MonoPInvokeCallback(typeof(JSNative.JSDelegate))] 30 | private static void PromiseReject(IntPtr id) 31 | { 32 | try 33 | { 34 | var handle = new JSHandle(id, true); 35 | if (!JSNative.IsObject(handle)) 36 | return; 37 | 38 | var promise = Acquire(handle); 39 | promise.OnReject(); 40 | promise.IsDone = true; 41 | promise.IsError = true; 42 | } 43 | catch (Exception e) 44 | { 45 | Log.Error($"Error happened on JSPromise.PromiseReject: {Environment.NewLine} {e.Message}"); 46 | } 47 | } 48 | 49 | public bool IsDone { get; private set; } 50 | public bool IsError { get; private set; } 51 | internal JSHandle ResolveHandle { get; private set; } 52 | internal JSHandle RejectHandle { get; private set; } 53 | 54 | [Preserve] 55 | internal JSPromise(JSHandle handle) : base(handle) 56 | { 57 | JSNative.PushFunction(NativeHandle, PromiseResolve, "PromiseResolve"); 58 | JSNative.PushFunction(NativeHandle, PromiseReject, "PromiseReject"); 59 | JSNative.CallMethod(NativeHandle, "then"); 60 | } 61 | 62 | protected virtual void OnResolve() 63 | { 64 | ResolveHandle = JSNative.ShiftStack(); 65 | } 66 | 67 | protected virtual void OnReject() 68 | { 69 | RejectHandle = JSNative.ShiftStack(); 70 | } 71 | 72 | // Coroutines impl 73 | public object Current => null; 74 | 75 | public bool MoveNext() 76 | { 77 | return !IsDone; 78 | } 79 | 80 | public void Reset() 81 | { 82 | // Ignore 83 | } 84 | } 85 | 86 | public class JSPromise : JSPromise where T : JSObject 87 | { 88 | public T ResolveValue { get; private set; } // Nullable 89 | 90 | [Preserve] 91 | internal JSPromise(JSHandle handle) : base(handle) 92 | { 93 | 94 | } 95 | 96 | protected override void OnResolve() 97 | { 98 | base.OnResolve(); 99 | if (JSNative.IsUndefined(ResolveHandle) || JSNative.IsNull(ResolveHandle)) 100 | return; 101 | 102 | ResolveValue = Acquire(ResolveHandle); 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSPromise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bae53b8f354d504ab39a2df151855c7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSRef.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEngine.Scripting; 5 | 6 | namespace LiveKit 7 | { 8 | public class JSRef 9 | { 10 | private static readonly Dictionary s_TypeMap = new Dictionary() 11 | { 12 | {"Error", typeof(JSError)}, 13 | {"Uint8Array", typeof(JSUint8Array)}, 14 | {"LivekitError", typeof(LivekitError)}, 15 | {"ConnectionError", typeof(ConnectionError)}, 16 | {"TrackInvalidError", typeof(TrackInvalidError)}, 17 | {"UnsupportedServer", typeof(UnsupportedServer)}, 18 | {"UnexpectedConnectionState", typeof(UnexpectedConnectionState)}, 19 | {"PublishDataError", typeof(PublishDataError)}, 20 | {"Room", typeof(Room)}, 21 | {"Participant", typeof(Participant)}, 22 | {"LocalParticipant", typeof(LocalParticipant)}, 23 | {"RemoteParticipant", typeof(RemoteParticipant)}, 24 | {"Track", typeof(Track)}, 25 | {"RemoteTrack", typeof(RemoteTrack)}, 26 | {"RemoteVideoTrack", typeof(RemoteVideoTrack)}, 27 | {"RemoteAudioTrack", typeof(RemoteAudioTrack)}, 28 | {"LocalTrack", typeof(LocalTrack)}, 29 | {"LocalVideoTrack", typeof(LocalVideoTrack)}, 30 | {"LocalAudioTrack", typeof(LocalAudioTrack)}, 31 | {"TrackPublication", typeof(TrackPublication)}, 32 | {"RemoteTrackPublication", typeof(RemoteTrackPublication)}, 33 | {"LocalTrackPublication", typeof(LocalTrackPublication)}, 34 | {"HTMLVideoElement", typeof(HTMLVideoElement)}, 35 | {"HTMLAudioElement", typeof(HTMLAudioElement)}, 36 | }; 37 | 38 | internal static readonly Dictionary> Cache = new Dictionary>(); 39 | internal static readonly HashSet AliveCache = new HashSet(); // Used to hold a reference and release it manually 40 | 41 | internal readonly JSHandle NativeHandle; // Own the handle 42 | 43 | internal static T Acquire(JSHandle handle) where T : JSRef 44 | { 45 | if (handle.IsClosed || handle.IsInvalid) 46 | throw new Exception("Trying to acquire an invalid handle"); 47 | 48 | var ptr = handle.DangerousGetHandle(); 49 | if (Cache.TryGetValue(ptr, out var wRef) && wRef.TryGetTarget(out JSRef jsRef)) 50 | return jsRef as T; 51 | 52 | var type = typeof(T); 53 | if (JSNative.IsObject(handle)) 54 | { 55 | // Maintain class hierarchy 56 | JSNative.PushString("constructor"); 57 | var ctor = JSNative.GetProperty(handle); 58 | 59 | JSNative.PushString("name"); 60 | var typeName = JSNative.GetString(JSNative.GetProperty(ctor)); 61 | 62 | if (s_TypeMap.TryGetValue(typeName, out Type correctType)) 63 | type = correctType; 64 | } 65 | 66 | return Activator.CreateInstance(type, BindingFlags.NonPublic | BindingFlags.Instance, null, new object[]{handle}, null) as T; 67 | } 68 | 69 | internal static void SetKeepAlive(object reff, bool keepAlive) 70 | { 71 | if (reff == null) 72 | throw new ArgumentNullException(nameof(reff)); 73 | 74 | Log.Debug($"SetKeepAlive of {reff} to {keepAlive}"); 75 | 76 | if (keepAlive) 77 | AliveCache.Add(reff); 78 | else 79 | AliveCache.Remove(reff); 80 | } 81 | 82 | [Preserve] 83 | internal JSRef(JSHandle handle) 84 | { 85 | NativeHandle = handle; 86 | 87 | // We add the instantiated object into the cache se we can retrieve it later if not garbage collected. 88 | // Note that if JSRef has been garbage collected, it doesn't mean that the key doesn't exists on this map ( Finalizer is unpredictable ) 89 | Cache[handle.DangerousGetHandle()] = new WeakReference(this); 90 | } 91 | 92 | internal JSRef() : this(JSNative.NewRef()) 93 | { 94 | 95 | } 96 | 97 | ~JSRef() 98 | { 99 | Dispose(false); 100 | } 101 | 102 | protected virtual void Dispose(bool disposing) 103 | { 104 | var ptr = NativeHandle.DangerousGetHandle(); 105 | Cache.Remove(ptr); 106 | 107 | if (disposing) 108 | { 109 | NativeHandle.Dispose(); 110 | } 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSRef.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a73c3eb3fbd0d741aee44da504adbf8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSUint8Array.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | public class JSUint8Array : JSObject 6 | { 7 | [Preserve] 8 | internal JSUint8Array(JSHandle handle) : base(handle) 9 | { 10 | 11 | } 12 | 13 | public int Length 14 | { 15 | get 16 | { 17 | JSNative.PushString("byteLength"); 18 | return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 19 | } 20 | } 21 | 22 | public byte[] ToArray() 23 | { 24 | var buff = new byte[Length]; 25 | JSNative.CopyData(NativeHandle, buff, 0, buff.Length); 26 | return buff; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/JSUint8Array.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1367026a3f7457db5ed685c171adb5b 3 | timeCreated: 1650359550 -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Log.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using UnityEngine; 3 | using Debug = UnityEngine.Debug; 4 | 5 | namespace LiveKit 6 | { 7 | internal static class Log 8 | { 9 | private const string PREFIX = "LKBridge:"; 10 | private const string LK_DEBUG = "LK_DEBUG"; 11 | 12 | [Conditional(LK_DEBUG)] 13 | public static void Debug(object msg) 14 | { 15 | UnityEngine.Debug.unityLogger.Log(LogType.Log, $"{PREFIX} {msg}"); 16 | } 17 | 18 | [Conditional(LK_DEBUG)] 19 | public static void DebugHandle(JSRef reff) 20 | { 21 | Utils.PrintHandle(reff); 22 | } 23 | 24 | public static void Error(object msg) 25 | { 26 | UnityEngine.Debug.unityLogger.Log(LogType.Error, $"{PREFIX} {msg}"); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Log.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df8ed6e1e5ec73841bff3564ebfbe4f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/MediaStreamTrack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | 7 | public class MediaStreamTrack : JSObject 8 | { 9 | 10 | [Preserve] 11 | internal MediaStreamTrack(JSHandle handle) : base(handle) 12 | { 13 | 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/MediaStreamTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 059e5b0da8144ba47bf1c7a4c04c5f65 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Proto.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace LiveKit 4 | { 5 | public enum DataPacketKind 6 | { 7 | RELIABLE = 0, 8 | LOSSY = 1, 9 | UNRECOGNIZED = -1, 10 | } 11 | 12 | public enum VideoQuality 13 | { 14 | LOW = 0, 15 | MEDIUM = 1, 16 | HIGH = 2, 17 | UNRECOGNIZED = -1, 18 | } 19 | 20 | public enum DisconnectReason { 21 | UNKNOWN_REASON = 0, 22 | CLIENT_INITIATED = 1, 23 | DUPLICATE_IDENTITY = 2, 24 | SERVER_SHUTDOWN = 3, 25 | PARTICIPANT_REMOVED = 4, 26 | ROOM_DELETED = 5, 27 | STATE_MISMATCH = 6, 28 | UNRECOGNIZED = -1, 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Proto.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cb9f4ec252ebb942aef5396a10214a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.Serialization; 4 | 5 | namespace LiveKit 6 | { 7 | public class Utils 8 | { 9 | internal static string ToEnumString(T type) 10 | { 11 | var eType = typeof(T); 12 | var name = Enum.GetName(eType, type); 13 | var attributes = ((EnumMemberAttribute[]) eType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); 14 | return attributes.Value; 15 | } 16 | 17 | internal static T ToEnum(string str) 18 | { 19 | var eType = typeof(T); 20 | foreach (var name in Enum.GetNames(eType)) 21 | { 22 | var attributes = ((EnumMemberAttribute[]) eType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single(); 23 | if (attributes.Value == str) 24 | return (T) Enum.Parse(eType, name); 25 | } 26 | 27 | throw new NullReferenceException("Enum not found"); 28 | } 29 | 30 | internal static bool IsNumber(Type type) 31 | { 32 | switch (Type.GetTypeCode(type)) 33 | { 34 | case TypeCode.Byte: 35 | case TypeCode.SByte: 36 | case TypeCode.UInt16: 37 | case TypeCode.UInt32: 38 | case TypeCode.UInt64: 39 | case TypeCode.Int16: 40 | case TypeCode.Int32: 41 | case TypeCode.Int64: 42 | case TypeCode.Decimal: 43 | case TypeCode.Double: 44 | case TypeCode.Single: 45 | return true; 46 | default: 47 | return false; 48 | } 49 | } 50 | 51 | public static void PrintHandle(JSHandle handle) 52 | { 53 | JSNative.PushString("console"); 54 | var console = JSNative.GetProperty(JSNative.Window); 55 | 56 | JSNative.PushObject(handle); 57 | JSNative.CallMethod(console, "log"); 58 | } 59 | 60 | public static void PrintHandle(JSRef reff) 61 | { 62 | PrintHandle(reff.NativeHandle); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce1c58c4a8200bb4da2ceaa6c8680fd0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/WebRTC.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System.Runtime.Serialization; 4 | 5 | namespace LiveKit 6 | { 7 | // https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints 8 | public struct ConstrainBoolean 9 | { 10 | [JsonProperty("exact")] 11 | public bool Exact; 12 | [JsonProperty("ideal")] 13 | public bool Ideal; 14 | 15 | public static implicit operator ConstrainBoolean(bool value) 16 | { 17 | return new ConstrainBoolean() 18 | { 19 | Exact = value 20 | }; 21 | } 22 | } 23 | 24 | public struct ConstrainDOMString 25 | { 26 | [JsonProperty("exact")] 27 | public string[] Exact; 28 | [JsonProperty("ideal")] 29 | public string[] Ideal; 30 | 31 | public static implicit operator ConstrainDOMString(string value) 32 | { 33 | return new ConstrainDOMString() 34 | { 35 | Exact = new string[] {value} 36 | }; 37 | } 38 | 39 | public static implicit operator ConstrainDOMString(string[] value) 40 | { 41 | return new ConstrainDOMString() 42 | { 43 | Exact = value 44 | }; 45 | } 46 | } 47 | 48 | public struct ConstrainULong 49 | { 50 | [JsonProperty("exact")] 51 | public ulong Exact; 52 | [JsonProperty("ideal")] 53 | public ulong Ideal; 54 | [JsonProperty("min")] 55 | public ulong Min; 56 | [JsonProperty("max")] 57 | public ulong Max; 58 | 59 | public static implicit operator ConstrainULong(ulong value) 60 | { 61 | return new ConstrainULong() 62 | { 63 | Exact = value 64 | }; 65 | } 66 | } 67 | 68 | public struct ConstrainDouble 69 | { 70 | [JsonProperty("exact")] 71 | public double Exact; 72 | [JsonProperty("ideal")] 73 | public double Ideal; 74 | [JsonProperty("min")] 75 | public double Min; 76 | [JsonProperty("max")] 77 | public double Max; 78 | 79 | public static implicit operator ConstrainDouble(double value) 80 | { 81 | return new ConstrainDouble() 82 | { 83 | Exact = value 84 | }; 85 | } 86 | } 87 | 88 | [JsonConverter(typeof(StringEnumConverter))] 89 | public enum RTCIceCredentialType 90 | { 91 | [EnumMember(Value = "oauth")] 92 | OAuth, 93 | [EnumMember(Value = "password")] 94 | Password, 95 | } 96 | 97 | [JsonConverter(typeof(StringEnumConverter))] 98 | public enum RTCBundlePolicy 99 | { 100 | [EnumMember(Value = "balanced")] 101 | Balanced, 102 | [EnumMember(Value = "max-bundle")] 103 | MaxBundle, 104 | [EnumMember(Value = "max-compat")] 105 | MaxCompat, 106 | } 107 | 108 | [JsonConverter(typeof(StringEnumConverter))] 109 | public enum RTCIceTransportPolicy 110 | { 111 | [EnumMember(Value = "all")] 112 | All, 113 | [EnumMember(Value = "relay")] 114 | Relay 115 | }; 116 | 117 | 118 | [JsonConverter(typeof(StringEnumConverter))] 119 | public enum RTCRtcpMuxPolicy 120 | { 121 | [EnumMember(Value = "require")] 122 | Require, 123 | [EnumMember(Value = "negotiate")] 124 | Negotiate, 125 | }; 126 | 127 | public struct RTCIceServer 128 | { 129 | [JsonProperty("credential")] 130 | public string Credential; 131 | [JsonProperty("credentialType")] 132 | public RTCIceCredentialType? CredentialType; 133 | [JsonProperty("urls")] 134 | public string[] URLs; 135 | [JsonProperty("username")] 136 | public string Username; 137 | } 138 | 139 | public struct RTCConfiguration 140 | { 141 | [JsonProperty("bundlePolicy")] 142 | public RTCBundlePolicy? BundlePolicy; 143 | [JsonProperty("certificates")] 144 | public JSRef[] Certificates; 145 | [JsonProperty("iceCandidatePoolSize")] 146 | public ushort? IceCandidatePoolSize; 147 | [JsonProperty("iceServers")] 148 | public RTCIceServer[] IceServers; 149 | [JsonProperty("iceTransportPolicy")] 150 | public RTCIceTransportPolicy? IceTransportPolicy; 151 | [JsonProperty("rtcpMuxPolicy")] 152 | public RTCRtcpMuxPolicy? RTCPMuxPolicy; 153 | } 154 | 155 | [JsonConverter(typeof(StringEnumConverter))] 156 | public enum MediaDeviceKind 157 | { 158 | [EnumMember(Value = "audioinput")] 159 | AudioInput, 160 | [EnumMember(Value = "audiooutput")] 161 | AudioOutput, 162 | [EnumMember(Value = "videoinput")] 163 | VideoInput 164 | } 165 | 166 | public struct MediaDeviceInfo 167 | { 168 | [JsonProperty("deviceId")] 169 | public string DeviceId; 170 | [JsonProperty("groupId")] 171 | public string GroupId; 172 | [JsonProperty("kind")] 173 | public MediaDeviceKind Kind; 174 | [JsonProperty("label")] 175 | public string Label; 176 | } 177 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Internal/WebRTC.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9e84d52fb083ee4591357af17ad60aa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | using System.Runtime.Serialization; 5 | 6 | namespace LiveKit 7 | { 8 | [JsonConverter(typeof(StringEnumConverter))] 9 | public enum LogLevel 10 | { 11 | [EnumMember(Value = "trace")] 12 | Trace, 13 | [EnumMember(Value = "debug")] 14 | Debug, 15 | [EnumMember(Value = "info")] 16 | Info, 17 | [EnumMember(Value = "warn")] 18 | Warn, 19 | [EnumMember(Value = "error")] 20 | Error, 21 | [EnumMember(Value = "silent")] 22 | Silent 23 | } 24 | 25 | public struct RoomOptions 26 | { 27 | [JsonProperty("adaptiveStream")] 28 | public bool AdaptiveStream; 29 | [JsonProperty("dynacast")] 30 | public bool Dynacast; 31 | [JsonProperty("audioCaptureDefaults")] 32 | public AudioCaptureOptions? AudioCaptureDefaults; 33 | [JsonProperty("videoCaptureDefaults")] 34 | public VideoCaptureOptions? VideoCaptureDefaults; 35 | [JsonProperty("publishDefaults")] 36 | public TrackPublishDefaults? PublishDefaults; 37 | [JsonProperty("stopLocalTrackOnUnpublish")] 38 | public bool StopLocalTrackOnUnpublish; 39 | [JsonProperty("expDisableLayerPause")] 40 | public bool ExpDisableLayerPause; 41 | } 42 | 43 | public struct RoomConnectOptions 44 | { 45 | [JsonProperty("autoSubscribe")] 46 | public bool AutoSubscribe; 47 | [JsonProperty("rtcConfig")] 48 | public RTCConfiguration? RTCConfig; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Runtime/Scripts/Options.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84a8b443d600af7438362c04e848d752 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3cec9b1302e50042bffc05c39a0bead 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Errors.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System.Runtime.Serialization; 4 | using UnityEngine.Scripting; 5 | 6 | namespace LiveKit 7 | { 8 | public class LivekitError : JSError 9 | { 10 | public int Code 11 | { 12 | get 13 | { 14 | JSNative.PushString("code"); 15 | return (int) JSNative.GetNumber(JSNative.GetProperty(NativeHandle)); 16 | } 17 | } 18 | 19 | [Preserve] 20 | internal LivekitError(JSHandle handle) : base(handle) 21 | { 22 | 23 | } 24 | } 25 | 26 | public class ConnectionError : LivekitError 27 | { 28 | [Preserve] 29 | internal ConnectionError(JSHandle handle) : base(handle) 30 | { 31 | 32 | } 33 | } 34 | 35 | public class TrackInvalidError : LivekitError 36 | { 37 | [Preserve] 38 | internal TrackInvalidError(JSHandle handle) : base(handle) 39 | { 40 | 41 | } 42 | } 43 | public class UnsupportedServer : LivekitError 44 | { 45 | [Preserve] 46 | internal UnsupportedServer(JSHandle handle) : base(handle) 47 | { 48 | 49 | } 50 | } 51 | 52 | public class UnexpectedConnectionState : LivekitError 53 | { 54 | [Preserve] 55 | internal UnexpectedConnectionState(JSHandle handle) : base(handle) 56 | { 57 | 58 | } 59 | } 60 | 61 | public class PublishDataError : LivekitError 62 | { 63 | [Preserve] 64 | internal PublishDataError(JSHandle handle) : base(handle) 65 | { 66 | 67 | } 68 | } 69 | 70 | [JsonConverter(typeof(StringEnumConverter))] 71 | public enum MediaDeviceFailure 72 | { 73 | [EnumMember(Value = "PermissionDenied")] 74 | PermissionDenied, 75 | [EnumMember(Value = "NotFound")] 76 | NotFound, 77 | [EnumMember(Value = "DeviceInUse")] 78 | DeviceInUse, 79 | [EnumMember(Value = "Other")] 80 | Other 81 | } 82 | 83 | public class Errors 84 | { 85 | public static MediaDeviceFailure? GetFailure(JSError error) 86 | { 87 | JSNative.PushString("MediaDeviceFailure"); 88 | var ptr = JSNative.GetProperty(JSNative.Window); 89 | 90 | JSNative.PushObject(error.NativeHandle); 91 | var rPtr = JSNative.CallMethod(ptr, "getFailure"); 92 | if (!JSNative.IsString(rPtr)) 93 | return null; 94 | 95 | return Utils.ToEnum(JSNative.GetString(rPtr)); 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Errors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e801c5205c3fce499496e3abdfd7b1c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbec331345b838f449344959fb5ee584 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/LocalParticipant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a14e3956f98c0d48adfdf93a183c4c8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/Participant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edb997f8c6fff5644a9e2df69edd3a7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/ParticipantTrackPermission.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace LiveKit 4 | { 5 | public struct ParticipantTrackPermission 6 | { 7 | [JsonProperty("participantIdentity")] 8 | public string ParticipantIdentity; 9 | [JsonProperty("allowAll")] 10 | public bool? AllowAll; 11 | [JsonProperty("allowedTrackSids")] 12 | public string[] AllowedTrackSids; 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/ParticipantTrackPermission.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 774e24459eae7834aa981ec999a0047b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/RemoteParticipant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | public class RemoteParticipant : Participant 7 | { 8 | [Preserve] 9 | internal RemoteParticipant(JSHandle handle) : base(handle) 10 | { 11 | 12 | } 13 | 14 | public void SetVolume(float volume) 15 | { 16 | JSNative.PushNumber(volume); 17 | JSNative.CallMethod(NativeHandle, "setVolume"); 18 | } 19 | 20 | public float GetVolume() 21 | { 22 | return (float) JSNative.GetNumber(JSNative.CallMethod(NativeHandle, "getVolume")); 23 | } 24 | 25 | public new RemoteTrackPublication GetTrackPublication(TrackSource source) 26 | { 27 | return base.GetTrackPublication(source) as RemoteTrackPublication; 28 | } 29 | 30 | public new RemoteTrackPublication GetTrackPublicationByName(string name) 31 | { 32 | return base.GetTrackPublicationByName(name) as RemoteTrackPublication; 33 | } 34 | 35 | 36 | public new RemoteTrackPublication GetTrackPublicationBySid(string sid) 37 | { 38 | return base.GetTrackPublicationBySid(sid) as RemoteTrackPublication; 39 | } 40 | 41 | public JSMap RemotePublications 42 | { 43 | get 44 | { 45 | JSNative.PushString("trackPublications"); 46 | return Acquire>(JSNative.GetProperty(NativeHandle)); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Participant/RemoteParticipant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05d5ea0dc253b094880de8a404078db6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Room.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 341d1262a0d2a89469008cc7dde6dd3f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c423574a6eb19d44d97559d85d985e1e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalAudioTrack.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | public class LocalAudioTrack : LocalTrack, IAudioTrack 7 | { 8 | [Preserve] 9 | internal LocalAudioTrack(JSHandle handle) : base(handle) 10 | { 11 | 12 | } 13 | 14 | public JSPromise SetDeviceId(string deviceId) 15 | { 16 | JSNative.PushString(deviceId); 17 | return Acquire(JSNative.CallMethod(NativeHandle, "setDeviceId")); 18 | } 19 | 20 | public JSPromise RestartTrack(AudioCaptureOptions? options = null) 21 | { 22 | if(options != null) 23 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 24 | 25 | return Acquire(JSNative.CallMethod(NativeHandle, "restartTrack")); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalAudioTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 027322b865420164abc81dde8c2edf98 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | public class LocalTrack : Track 6 | { 7 | [Preserve] 8 | internal LocalTrack(JSHandle handle) : base(handle) 9 | { 10 | 11 | } 12 | 13 | public string GetId() 14 | { 15 | return JSNative.GetString(JSNative.CallMethod(NativeHandle, "id")); 16 | } 17 | 18 | public TrackDimensions? GetDimensions() 19 | { 20 | var ptr = JSNative.CallMethod(NativeHandle, "dimensions"); 21 | if (!JSNative.IsObject(ptr)) 22 | return null; 23 | 24 | return JSNative.GetStruct(ptr); 25 | } 26 | 27 | public DeviceIdPromise GetDeviceId() 28 | { 29 | return Acquire(JSNative.CallMethod(NativeHandle, "getDeviceId")); 30 | } 31 | 32 | public JSPromise Mute() 33 | { 34 | return Acquire>(JSNative.CallMethod(NativeHandle, "mute")); 35 | } 36 | 37 | public JSPromise Unmute() 38 | { 39 | return Acquire>(JSNative.CallMethod(NativeHandle, "unmute")); 40 | } 41 | } 42 | 43 | public class DeviceIdPromise : JSPromise 44 | { 45 | public string DeviceId { get; private set; } 46 | 47 | [Preserve] 48 | internal DeviceIdPromise(JSHandle handle) : base(handle) 49 | { 50 | 51 | } 52 | 53 | protected override void OnResolve() 54 | { 55 | base.OnResolve(); 56 | if (!JSNative.IsUndefined(ResolveHandle)) 57 | DeviceId = JSNative.GetString(ResolveHandle); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37a4c8640e9401c458da21817801c30d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalTrackPublication.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | public class LocalTrackPublication : TrackPublication 6 | { 7 | public new LocalTrack Track => base.Track as LocalTrack; 8 | public new LocalAudioTrack AudioTrack => base.AudioTrack as LocalAudioTrack; 9 | public new LocalVideoTrack VideoTrack => base.VideoTrack as LocalVideoTrack; 10 | 11 | public TrackPublishOptions? Options 12 | { 13 | get 14 | { 15 | JSNative.PushString("dimensions"); 16 | var handle = JSNative.GetProperty(NativeHandle); 17 | if (JSNative.IsUndefined(handle) || JSNative.IsNull(handle)) 18 | return null; 19 | 20 | return JSNative.GetStruct(handle); 21 | } 22 | } 23 | 24 | [Preserve] 25 | internal LocalTrackPublication(JSHandle handle) : base(handle) 26 | { 27 | 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalTrackPublication.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9924682cd650206409bed56fe8af736d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalVideoTrack.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using UnityEngine.Scripting; 4 | 5 | namespace LiveKit 6 | { 7 | public class LocalVideoTrack : LocalTrack, IVideoTrack 8 | { 9 | 10 | public bool IsSimulcast 11 | { 12 | get 13 | { 14 | JSNative.PushString("isSimulcast"); 15 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 16 | } 17 | } 18 | 19 | [Preserve] 20 | internal LocalVideoTrack(JSHandle handle) : base(handle) 21 | { 22 | 23 | } 24 | 25 | public void SetPublishingQuality(VideoQuality maxQuality) 26 | { 27 | JSNative.PushNumber((double)maxQuality); 28 | JSNative.CallMethod(NativeHandle, "setPublishingQuality"); 29 | } 30 | 31 | public JSPromise SetDeviceId(string deviceId) 32 | { 33 | JSNative.PushString(deviceId); 34 | return Acquire(JSNative.CallMethod(NativeHandle, "setDeviceId")); 35 | } 36 | 37 | public JSPromise RestartTrack(VideoCaptureOptions? options = null) 38 | { 39 | if (options != null) 40 | JSNative.PushStruct(JsonConvert.SerializeObject(options, JSNative.JsonSettings)); 41 | 42 | return Acquire(JSNative.CallMethod(NativeHandle, "restartTrack")); 43 | } 44 | 45 | public JSPromise SetProcessor(JSHandle processor, bool showProcessedStreamLocally = true) 46 | { 47 | JSNative.PushObject(processor); 48 | JSNative.PushBoolean(showProcessedStreamLocally); 49 | return Acquire(JSNative.CallMethod (NativeHandle, "setProcessor")); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/LocalVideoTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 551b3629916e9454bb3c3ad0a157773d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/Options.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dba796c2c5aea640851d41715fd0a28 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteAudioTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | public class RemoteAudioTrack : RemoteTrack, IAudioTrack 6 | { 7 | [Preserve] 8 | internal RemoteAudioTrack(JSHandle handle) : base(handle) 9 | { 10 | 11 | } 12 | 13 | public void SetVolume(float volume) 14 | { 15 | JSNative.PushNumber(volume); 16 | JSNative.CallMethod(NativeHandle, "setVolume"); 17 | } 18 | 19 | public float GetVolume() 20 | { 21 | return (float) JSNative.GetNumber(JSNative.CallMethod(NativeHandle, "getVolume")); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteAudioTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 878eb94680087d443af2fa0496313476 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteTrack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Scripting; 2 | 3 | namespace LiveKit 4 | { 5 | 6 | public class RemoteTrack : Track 7 | { 8 | [Preserve] 9 | internal RemoteTrack(JSHandle handle) : base(handle) 10 | { 11 | 12 | } 13 | 14 | public void Start() 15 | { 16 | JSNative.CallMethod(NativeHandle, "start"); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccfb21e8648b59d48969fdfbb2378fbe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteTrackPublication.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | 7 | public class RemoteTrackPublication : TrackPublication 8 | { 9 | public new RemoteTrack Track => base.Track as RemoteTrack; 10 | 11 | public SubscriptionStatus SubscriptionStatus 12 | { 13 | get 14 | { 15 | JSNative.PushString("subscriptionStatus"); 16 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 17 | } 18 | } 19 | 20 | public VideoQuality? VideoQuality 21 | { 22 | get 23 | { 24 | JSNative.PushString("videoQuality"); 25 | var ptr = JSNative.GetProperty(NativeHandle); 26 | if (!JSNative.IsNumber(ptr)) 27 | return null; 28 | 29 | return (VideoQuality?) JSNative.GetNumber(ptr); 30 | } 31 | } 32 | 33 | 34 | [Preserve] 35 | internal RemoteTrackPublication(JSHandle handle) : base(handle) 36 | { 37 | 38 | } 39 | 40 | public void SetSubscribed(bool subscribed) 41 | { 42 | JSNative.PushBoolean(subscribed); 43 | JSNative.CallMethod(NativeHandle, "setSubscribed"); 44 | } 45 | 46 | public void SetEnabled(bool enabled) 47 | { 48 | JSNative.PushBoolean(enabled); 49 | JSNative.CallMethod(NativeHandle, "setEnabled"); 50 | } 51 | 52 | public void SetVideoQuality(VideoQuality quality) 53 | { 54 | JSNative.PushNumber((double)quality); 55 | JSNative.CallMethod(NativeHandle, "setVideoQuality"); 56 | } 57 | 58 | public void SetVideoDimensions(TrackDimensions dimensions) 59 | { 60 | JSNative.PushStruct(JsonConvert.SerializeObject(dimensions, JSNative.JsonSettings)); 61 | JSNative.CallMethod(NativeHandle, "setVideoDimensions"); 62 | } 63 | 64 | public void SetTrack(Track track = null) 65 | { 66 | if (track != null) 67 | JSNative.PushObject(track.NativeHandle); 68 | 69 | JSNative.CallMethod(NativeHandle, "setTrack"); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteTrackPublication.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c2ea4d5f80afb044ac9ebf7af446162 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteVideoTrack.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEngine.Scripting; 3 | 4 | namespace LiveKit 5 | { 6 | public class RemoteVideoTrack : RemoteTrack, IVideoTrack 7 | { 8 | public bool IsAdaptiveStream 9 | { 10 | get 11 | { 12 | JSNative.PushString("isAdaptiveStream"); 13 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 14 | } 15 | } 16 | 17 | [Preserve] 18 | internal RemoteVideoTrack(JSHandle handle) : base(handle) 19 | { 20 | 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/RemoteVideoTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa4099b49bf6e814cbc402a053b4b914 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8e267fa9b9744889c288ac27302874c 3 | timeCreated: 1651835470 -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/IAudioTrack.cs: -------------------------------------------------------------------------------- 1 | namespace LiveKit 2 | { 3 | public interface IAudioTrack : ITrack 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/IAudioTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51a90a7f785a43eba287671e025aa9ed 3 | timeCreated: 1651837150 -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/ITrack.cs: -------------------------------------------------------------------------------- 1 | namespace LiveKit 2 | { 3 | public interface ITrack 4 | { 5 | public delegate void MessageDelegate(); 6 | public delegate void MutedDelegate(Track track); 7 | public delegate void UnmutedDelegate(Track track); 8 | public delegate void EndedDelegate(Track track); 9 | public delegate void ElementAttachedDelegate(HTMLMediaElement element); 10 | public delegate void ElementDetachedDelegate(HTMLMediaElement element); 11 | 12 | event MessageDelegate Message; 13 | event MutedDelegate Muted; 14 | event UnmutedDelegate Unmuted; 15 | event EndedDelegate Ended; 16 | event ElementAttachedDelegate ElementAttached; 17 | event ElementDetachedDelegate ElementDetached; 18 | 19 | TrackKind Kind { get; } 20 | MediaStreamTrack MediaStreamTrack { get; } 21 | JSArray AttachedElements { get; } 22 | bool IsMuted { get; } 23 | TrackSource Source { get; } 24 | string Sid { get; } 25 | HTMLMediaElement Attach(); 26 | JSArray Detach(); 27 | void Stop(); 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/ITrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34ef6625359e4b40a6c45ead27551d1d 3 | timeCreated: 1651835632 -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/IVideoTrack.cs: -------------------------------------------------------------------------------- 1 | namespace LiveKit 2 | { 3 | public interface IVideoTrack : ITrack 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TSInterop/IVideoTrack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 358e3ee8dd414055aa8b040698e38d80 3 | timeCreated: 1651836829 -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/Track.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System; 4 | using System.Runtime.Serialization; 5 | using AOT; 6 | using UnityEngine.Scripting; 7 | 8 | namespace LiveKit 9 | { 10 | [JsonConverter(typeof(StringEnumConverter))] 11 | public enum TrackKind 12 | { 13 | [EnumMember(Value = "audio")] 14 | Audio, 15 | [EnumMember(Value = "video")] 16 | Video, 17 | [EnumMember(Value = "unknown")] 18 | Unknown, 19 | } 20 | 21 | [JsonConverter(typeof(StringEnumConverter))] 22 | public enum TrackSource 23 | { 24 | [EnumMember(Value = "camera")] 25 | Camera, 26 | [EnumMember(Value = "microphone")] 27 | Microphone, 28 | [EnumMember(Value = "screen_share")] 29 | ScreenShare, 30 | [EnumMember(Value = "screen_share_audio")] 31 | ScreenShareAudio, 32 | [EnumMember(Value = "unknown")] 33 | Unknown, 34 | } 35 | 36 | [JsonConverter(typeof(StringEnumConverter))] 37 | public enum TrackStreamState 38 | { 39 | [EnumMember(Value = "active")] 40 | Active, 41 | [EnumMember(Value = "paused")] 42 | Paused, 43 | [EnumMember(Value = "unknown")] 44 | Unknown, 45 | } 46 | 47 | public struct TrackDimensions 48 | { 49 | [JsonProperty("width")] 50 | public int Width; 51 | [JsonProperty("height")] 52 | public int Height; 53 | } 54 | 55 | public class Track : JSEventEmitter, ITrack 56 | { 57 | public event ITrack.MessageDelegate Message; 58 | public event ITrack.MutedDelegate Muted; 59 | public event ITrack.UnmutedDelegate Unmuted; 60 | public event ITrack.EndedDelegate Ended; 61 | public event ITrack.ElementAttachedDelegate ElementAttached; 62 | public event ITrack.ElementDetachedDelegate ElementDetached; 63 | 64 | public TrackKind Kind 65 | { 66 | get 67 | { 68 | JSNative.PushString("kind"); 69 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 70 | } 71 | } 72 | 73 | public MediaStreamTrack MediaStreamTrack 74 | { 75 | get 76 | { 77 | JSNative.PushString("mediaStreamTrack"); 78 | return Acquire(JSNative.GetProperty(NativeHandle)); 79 | } 80 | } 81 | 82 | public JSArray AttachedElements 83 | { 84 | get 85 | { 86 | JSNative.PushString("attachedElements"); 87 | return Acquire>(JSNative.GetProperty(NativeHandle)); 88 | } 89 | } 90 | 91 | public bool IsMuted 92 | { 93 | get 94 | { 95 | JSNative.PushString("isMuted"); 96 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 97 | } 98 | } 99 | 100 | public TrackSource Source 101 | { 102 | get 103 | { 104 | JSNative.PushString("source"); 105 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 106 | } 107 | } 108 | 109 | public string Sid 110 | { 111 | get 112 | { 113 | JSNative.PushString("sid"); 114 | var ptr = JSNative.GetProperty(NativeHandle); 115 | if (!JSNative.IsString(ptr)) 116 | return null; 117 | 118 | return JSNative.GetString(ptr); 119 | } 120 | } 121 | 122 | public TrackStreamState StreamState 123 | { 124 | get 125 | { 126 | JSNative.PushString("streamState"); 127 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 128 | } 129 | } 130 | 131 | [MonoPInvokeCallback(typeof(JSNative.JSDelegate))] 132 | private static void EventReceived(IntPtr iptr) 133 | { 134 | var handle = new JSHandle(iptr, true); 135 | var evRef = Acquire(handle); 136 | try 137 | { 138 | var track = Acquire(JSNative.GetFunctionInstance()); 139 | 140 | switch (evRef.Event) 141 | { 142 | case TrackEvent.Message: 143 | track.Message?.Invoke(); 144 | Log.Debug($"Track: Message()"); 145 | break; 146 | case TrackEvent.Muted: 147 | { 148 | var ptr = JSNative.ShiftStack(); 149 | Track t = null; 150 | if(JSNative.IsObject(ptr)) 151 | t = Acquire(ptr); 152 | 153 | Log.Debug($"Track: Muted({t})"); 154 | track.Muted?.Invoke(t); 155 | break; 156 | } 157 | case TrackEvent.Unmuted: 158 | { 159 | var ptr = JSNative.ShiftStack(); 160 | Track t = null; 161 | if(JSNative.IsObject(ptr)) 162 | t = Acquire(ptr); 163 | 164 | Log.Debug($"Track: Unmuted({t})"); 165 | track.Unmuted?.Invoke(t); 166 | break; 167 | } 168 | case TrackEvent.Ended: 169 | { 170 | var ptr = JSNative.ShiftStack(); 171 | Track t = null; 172 | if(JSNative.IsObject(ptr)) 173 | t = Acquire(ptr); 174 | 175 | Log.Debug($"Track: Ended({t})"); 176 | track.Ended?.Invoke(t); 177 | break; 178 | } 179 | case TrackEvent.ElementAttached: 180 | { 181 | var element = Acquire(JSNative.ShiftStack()); 182 | Log.Debug($"Track: ElementAttached({element})"); 183 | track.ElementAttached?.Invoke(element); 184 | break; 185 | } 186 | case TrackEvent.ElementDetached: 187 | { 188 | var element = Acquire(JSNative.ShiftStack()); 189 | Log.Debug($"Track: ElementDetached({element})"); 190 | track.ElementDetached?.Invoke(element); 191 | break; 192 | } 193 | } 194 | } 195 | catch (Exception e) 196 | { 197 | Log.Error($"Error happened on TrackEvent.{evRef.Event} ( Is your listeners working correctly ? ): {Environment.NewLine} {e.Message}"); 198 | } 199 | } 200 | 201 | [Preserve] 202 | internal Track(JSHandle handle) : base(handle) 203 | { 204 | RegisterEvents(); 205 | 206 | // This is required for video because in finalization of HTMLVideoElement, we destroy the 207 | // WebGL texture 208 | ElementAttached += element => SetKeepAlive(element, true); 209 | ElementDetached += element => SetKeepAlive(element, false); 210 | } 211 | 212 | private void RegisterEvents() 213 | { 214 | foreach (var e in Enum.GetValues(typeof(TrackEvent))) 215 | SetListener((TrackEvent) e, EventReceived); 216 | } 217 | 218 | public HTMLMediaElement Attach() 219 | { 220 | return Acquire(JSNative.CallMethod(NativeHandle, "attach")); 221 | } 222 | 223 | public JSArray Detach() 224 | { 225 | return Acquire>(JSNative.CallMethod(NativeHandle, "detach")); 226 | } 227 | 228 | public void Stop() 229 | { 230 | JSNative.CallMethod(NativeHandle, "stop"); 231 | } 232 | } 233 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/Track.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56a2ebd9ca696e94280de90c2b3a3706 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TrackPublication.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | using System; 4 | using System.Runtime.Serialization; 5 | using UnityEngine.Scripting; 6 | 7 | namespace LiveKit 8 | { 9 | [JsonConverter(typeof(StringEnumConverter))] 10 | public enum SubscriptionStatus 11 | { 12 | [EnumMember(Value = "subscribed")] 13 | Subscribed, 14 | [EnumMember(Value = "not_allowed")] 15 | NotAllowed, 16 | [EnumMember(Value = "unsubscribed")] 17 | Unsubscribed 18 | } 19 | 20 | public class TrackPublication : JSObject 21 | { 22 | public TrackKind Kind 23 | { 24 | get 25 | { 26 | JSNative.PushString("kind"); 27 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 28 | } 29 | } 30 | 31 | public string TrackName 32 | { 33 | get 34 | { 35 | JSNative.PushString("trackName"); 36 | return JSNative.GetString(JSNative.GetProperty(NativeHandle)); 37 | } 38 | } 39 | 40 | public string TrackSid 41 | { 42 | get 43 | { 44 | JSNative.PushString("trackSid"); 45 | return JSNative.GetString(JSNative.GetProperty(NativeHandle)); 46 | } 47 | } 48 | 49 | public Track Track 50 | { 51 | get 52 | { 53 | JSNative.PushString("track"); 54 | var ptr = JSNative.GetProperty(NativeHandle); 55 | if (!JSNative.IsObject(ptr)) 56 | return null; 57 | 58 | return Acquire(ptr); 59 | } 60 | } 61 | 62 | public TrackSource Source 63 | { 64 | get 65 | { 66 | JSNative.PushString("source"); 67 | return Utils.ToEnum(JSNative.GetString(JSNative.GetProperty(NativeHandle))); 68 | } 69 | } 70 | 71 | public string MimeType 72 | { 73 | get 74 | { 75 | JSNative.PushString("mimeType"); 76 | var ptr = JSNative.GetProperty(NativeHandle); 77 | if (!JSNative.IsString(ptr)) 78 | return null; 79 | 80 | return JSNative.GetString(ptr); 81 | } 82 | } 83 | 84 | public TrackDimensions? Dimensions 85 | { 86 | get 87 | { 88 | JSNative.PushString("dimensions"); 89 | var ptr = JSNative.GetProperty(NativeHandle); 90 | if (!JSNative.IsObject(ptr)) 91 | return null; 92 | 93 | return JSNative.GetStruct(ptr); 94 | } 95 | } 96 | 97 | public bool? Simulcasted 98 | { 99 | get 100 | { 101 | JSNative.PushString("simulcasted"); 102 | var ptr = JSNative.GetProperty(NativeHandle); 103 | if (!JSNative.GetBoolean(ptr)) 104 | return null; 105 | 106 | return JSNative.GetBoolean(ptr); 107 | } 108 | } 109 | 110 | public bool IsMuted 111 | { 112 | get 113 | { 114 | JSNative.PushString("isMuted"); 115 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 116 | } 117 | } 118 | 119 | public bool IsEnabled 120 | { 121 | get 122 | { 123 | JSNative.PushString("isEnabled"); 124 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 125 | } 126 | } 127 | 128 | public bool IsSubscribed 129 | { 130 | get 131 | { 132 | JSNative.PushString("isSubscribed"); 133 | return JSNative.GetBoolean(JSNative.GetProperty(NativeHandle)); 134 | } 135 | } 136 | 137 | public Track AudioTrack 138 | { 139 | get 140 | { 141 | JSNative.PushString("audioTrack"); 142 | var ptr = JSNative.GetProperty(NativeHandle); 143 | if (!JSNative.IsObject(ptr)) 144 | return null; 145 | 146 | return Acquire(ptr); 147 | } 148 | } 149 | 150 | public Track VideoTrack 151 | { 152 | get 153 | { 154 | JSNative.PushString("videoTrack"); 155 | var ptr = JSNative.GetProperty(NativeHandle); 156 | if (!JSNative.IsObject(ptr)) 157 | return null; 158 | 159 | return Acquire(ptr); 160 | } 161 | } 162 | 163 | 164 | [Preserve] 165 | internal TrackPublication(JSHandle handle) : base(handle) 166 | { 167 | 168 | } 169 | } 170 | } -------------------------------------------------------------------------------- /Runtime/Scripts/Room/Track/TrackPublication.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 343ef6eaefa563847a9b9716cf39ca3c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/livekit.unity.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "LiveKitBridge", 3 | "rootNamespace": "LiveKit", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor", 7 | "WebGL" 8 | ], 9 | "excludePlatforms": [], 10 | "allowUnsafeCode": true, 11 | "overrideReferences": false, 12 | "precompiledReferences": [], 13 | "autoReferenced": true, 14 | "defineConstraints": [], 15 | "versionDefines": [], 16 | "noEngineReferences": false 17 | } -------------------------------------------------------------------------------- /Runtime/livekit.unity.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea9451ff16a9bab499ea5677a2d67939 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/CopyPaste.cs: -------------------------------------------------------------------------------- 1 | using AOT; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using UnityEngine; 5 | 6 | 7 | /* 8 | * This script is only used as a workaround for copying and pasting text into text fields, 9 | * as it is not supported by Unity on the WebGL platform. You can ignore it 10 | */ 11 | public class CopyPaste 12 | { 13 | #if UNITY_WEBGL && !UNITY_EDITOR 14 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] 15 | private static void Init() 16 | { 17 | InitCopyPaste(PasteReceived); 18 | } 19 | 20 | [MonoPInvokeCallback(typeof(Action))] 21 | private static void PasteReceived(string data) 22 | { 23 | GUIUtility.systemCopyBuffer = data; 24 | } 25 | 26 | [DllImport("__Internal")] 27 | internal static extern void InitCopyPaste(Action action); 28 | #endif 29 | } 30 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/CopyPaste.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 234faf79bc0b39f40ab8f97070569fbd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ExampleAssembly.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RoomExample", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:ae3e71e072a29bd4fb43afb30ec62dd1" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ExampleAssembly.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fe7ac1638990354a99859ce9e40c6a9 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ExampleRoom.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | using LiveKit; 5 | using System.Collections.Generic; 6 | using UnityEngine.SceneManagement; 7 | 8 | public class ExampleRoom : MonoBehaviour 9 | { 10 | private Dictionary m_Videos = new Dictionary(); 11 | private Room m_Room; 12 | 13 | public GridLayoutGroup ViewContainer; 14 | public RawImage ViewPrefab; 15 | public Button DisconnectButton; 16 | 17 | IEnumerator Start() 18 | { 19 | // New Room must be called when WebGL assembly is loaded 20 | m_Room = new Room(); 21 | 22 | // Setup the callbacks before connecting to the Room 23 | m_Room.ParticipantConnected += (p) => 24 | { 25 | Debug.Log($"Participant connected: {p.Sid}"); 26 | }; 27 | 28 | m_Room.LocalTrackPublished += (publication, participant) => HandleAddedTrack(publication.Track, publication); 29 | m_Room.LocalTrackUnpublished += (publication, participant) => HandleRemovedTrack(publication.Track, publication); 30 | m_Room.TrackSubscribed += (track, publication, participant) => HandleAddedTrack(track, publication); 31 | m_Room.TrackUnsubscribed += (track, publication, participant) => HandleRemovedTrack(track, publication); 32 | 33 | var c = m_Room.Connect(JoinMenu.LivekitURL, JoinMenu.RoomToken); 34 | yield return c; 35 | 36 | if (c.IsError) 37 | { 38 | Debug.Log("Failed to connect to the room !"); 39 | yield break; 40 | } 41 | 42 | Debug.Log("Connected to the room"); 43 | 44 | DisconnectButton.onClick.AddListener(() => 45 | { 46 | m_Room.Disconnect(); 47 | SceneManager.LoadScene("JoinScene", LoadSceneMode.Single); 48 | }); 49 | 50 | yield return m_Room.LocalParticipant.EnableCameraAndMicrophone(); 51 | } 52 | 53 | private void HandleAddedTrack(Track track, TrackPublication publication) 54 | { 55 | if (track.Kind == TrackKind.Video) 56 | { 57 | if (ViewContainer.transform.childCount >= 6) 58 | return; // No space to show more than 6 tracks 59 | 60 | var video = track.Attach() as HTMLVideoElement; 61 | var newView = Instantiate(ViewPrefab, ViewContainer.transform); 62 | m_Videos.Add(publication, newView); 63 | 64 | video.VideoReceived += tex => 65 | { 66 | newView.texture = tex; 67 | }; 68 | } 69 | else if (track.Kind == TrackKind.Audio && publication is RemoteTrackPublication) 70 | { 71 | track.Attach(); 72 | } 73 | } 74 | 75 | private void HandleRemovedTrack(Track track, TrackPublication publication) 76 | { 77 | track.Detach(); 78 | 79 | if (m_Videos.TryGetValue(publication, out var view)) 80 | Destroy(view.gameObject); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ExampleRoom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a25797c83fcd118479726fe7a937202e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/JoinMenu.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | using LiveKit; 5 | using UnityEngine.SceneManagement; 6 | 7 | public class JoinMenu : MonoBehaviour 8 | { 9 | public static string LivekitURL { get; private set; } 10 | public static string RoomToken { get; private set; } 11 | 12 | private LocalVideoTrack m_PreviewTrack; 13 | public RawImage PreviewCamera; 14 | public InputField URLField; 15 | public InputField TokenField; 16 | public Button ConnectButton; 17 | 18 | void Start() 19 | { 20 | StartCoroutine(StartPreviewCamera()); 21 | 22 | ConnectButton.onClick.AddListener(() => 23 | { 24 | LivekitURL = URLField.text; 25 | RoomToken = TokenField.text; 26 | 27 | if (string.IsNullOrWhiteSpace(RoomToken)) 28 | return; 29 | 30 | m_PreviewTrack?.Detach(); 31 | m_PreviewTrack?.Stop(); 32 | SceneManager.LoadScene("RoomScene", LoadSceneMode.Single); 33 | }); 34 | } 35 | 36 | private IEnumerator StartPreviewCamera() 37 | { 38 | var f = Client.CreateLocalVideoTrack(); 39 | yield return f; 40 | 41 | if (f.IsError) 42 | yield break; 43 | 44 | m_PreviewTrack = f.ResolveValue; 45 | 46 | var video = m_PreviewTrack.Attach() as HTMLVideoElement; 47 | video.VideoReceived += tex => 48 | { 49 | PreviewCamera.texture = tex; 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/JoinMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d1ff4fa24862c648b2225164c285661 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/JoinScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb44dd56904b83c458715961d83b5530 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ParticipantView.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1032180714691947334 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 1032180714691947335} 12 | - component: {fileID: 1032180714691947337} 13 | - component: {fileID: 1032180714691947336} 14 | m_Layer: 5 15 | m_Name: Text 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!224 &1032180714691947335 22 | RectTransform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1032180714691947334} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_ConstrainProportionsScale: 0 32 | m_Children: [] 33 | m_Father: {fileID: 1032180714776240066} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | m_AnchorMin: {x: 0.5, y: 0.5} 37 | m_AnchorMax: {x: 0.5, y: 0.5} 38 | m_AnchoredPosition: {x: -0.00023842, y: -30.581} 39 | m_SizeDelta: {x: 150.26, y: 18.7921} 40 | m_Pivot: {x: 0.5, y: 1.3712121} 41 | --- !u!222 &1032180714691947337 42 | CanvasRenderer: 43 | m_ObjectHideFlags: 0 44 | m_CorrespondingSourceObject: {fileID: 0} 45 | m_PrefabInstance: {fileID: 0} 46 | m_PrefabAsset: {fileID: 0} 47 | m_GameObject: {fileID: 1032180714691947334} 48 | m_CullTransparentMesh: 1 49 | --- !u!114 &1032180714691947336 50 | MonoBehaviour: 51 | m_ObjectHideFlags: 0 52 | m_CorrespondingSourceObject: {fileID: 0} 53 | m_PrefabInstance: {fileID: 0} 54 | m_PrefabAsset: {fileID: 0} 55 | m_GameObject: {fileID: 1032180714691947334} 56 | m_Enabled: 1 57 | m_EditorHideFlags: 0 58 | m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} 59 | m_Name: 60 | m_EditorClassIdentifier: 61 | m_Material: {fileID: 0} 62 | m_Color: {r: 1, g: 1, b: 1, a: 1} 63 | m_RaycastTarget: 1 64 | m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} 65 | m_Maskable: 1 66 | m_OnCullStateChanged: 67 | m_PersistentCalls: 68 | m_Calls: [] 69 | m_FontData: 70 | m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} 71 | m_FontSize: 12 72 | m_FontStyle: 1 73 | m_BestFit: 0 74 | m_MinSize: 1 75 | m_MaxSize: 40 76 | m_Alignment: 4 77 | m_AlignByGeometry: 0 78 | m_RichText: 0 79 | m_HorizontalOverflow: 0 80 | m_VerticalOverflow: 0 81 | m_LineSpacing: 1 82 | m_Text: Participant 83 | --- !u!1 &1032180714776240065 84 | GameObject: 85 | m_ObjectHideFlags: 0 86 | m_CorrespondingSourceObject: {fileID: 0} 87 | m_PrefabInstance: {fileID: 0} 88 | m_PrefabAsset: {fileID: 0} 89 | serializedVersion: 6 90 | m_Component: 91 | - component: {fileID: 1032180714776240066} 92 | - component: {fileID: 1032180714776240068} 93 | - component: {fileID: 1032180714776240067} 94 | m_Layer: 5 95 | m_Name: ParticipantView 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!224 &1032180714776240066 102 | RectTransform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 1032180714776240065} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_ConstrainProportionsScale: 0 112 | m_Children: 113 | - {fileID: 1032180714691947335} 114 | m_Father: {fileID: 0} 115 | m_RootOrder: 0 116 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 117 | m_AnchorMin: {x: 0, y: 0} 118 | m_AnchorMax: {x: 0, y: 0} 119 | m_AnchoredPosition: {x: 0, y: 0} 120 | m_SizeDelta: {x: 0, y: 0} 121 | m_Pivot: {x: 0.5, y: 0.5} 122 | --- !u!222 &1032180714776240068 123 | CanvasRenderer: 124 | m_ObjectHideFlags: 0 125 | m_CorrespondingSourceObject: {fileID: 0} 126 | m_PrefabInstance: {fileID: 0} 127 | m_PrefabAsset: {fileID: 0} 128 | m_GameObject: {fileID: 1032180714776240065} 129 | m_CullTransparentMesh: 1 130 | --- !u!114 &1032180714776240067 131 | MonoBehaviour: 132 | m_ObjectHideFlags: 0 133 | m_CorrespondingSourceObject: {fileID: 0} 134 | m_PrefabInstance: {fileID: 0} 135 | m_PrefabAsset: {fileID: 0} 136 | m_GameObject: {fileID: 1032180714776240065} 137 | m_Enabled: 1 138 | m_EditorHideFlags: 0 139 | m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3} 140 | m_Name: 141 | m_EditorClassIdentifier: 142 | m_Material: {fileID: 0} 143 | m_Color: {r: 1, g: 1, b: 1, a: 1} 144 | m_RaycastTarget: 1 145 | m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} 146 | m_Maskable: 1 147 | m_OnCullStateChanged: 148 | m_PersistentCalls: 149 | m_Calls: [] 150 | m_Texture: {fileID: 0} 151 | m_UVRect: 152 | serializedVersion: 2 153 | x: 0 154 | y: 0 155 | width: 1 156 | height: 1 157 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/ParticipantView.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83584d27641c43b4c89ce96f1e8c38a8 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/RoomScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a32acf433673f6a4bb20365f3c51c040 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/copy-paste.jslib: -------------------------------------------------------------------------------- 1 | var NativeLib = { 2 | 3 | InitCopyPaste: function (fnc) { 4 | window.addEventListener('paste', function (e) { 5 | var data = e.clipboardData.getData('text'); 6 | var bufferSize = lengthBytesUTF8(data) + 1; 7 | var buffer = _malloc(bufferSize); 8 | stringToUTF8(data, buffer, bufferSize); 9 | 10 | if (typeof Runtime !== "undefined") { 11 | Runtime.dynCall("vi", fnc, [buffer]); 12 | } else { 13 | dynCall("vi", fnc, [buffer]); 14 | } 15 | }); 16 | }, 17 | 18 | }; 19 | 20 | mergeInto(LibraryManager.library, NativeLib); -------------------------------------------------------------------------------- /Samples~/ExampleRoom/copy-paste.jslib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68c9e39ca735aea4f990f6dae0111012 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | WebGL: WebGL 27 | second: 28 | enabled: 1 29 | settings: {} 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /Samples~/ExampleRoom/livekit-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/Samples~/ExampleRoom/livekit-logo.png -------------------------------------------------------------------------------- /Samples~/ExampleRoom/livekit-logo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e4be5ef410696042b71c3519113ecdc 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: 1 36 | aniso: 1 37 | mipBias: 0 38 | wrapU: 1 39 | wrapV: 1 40 | wrapW: 0 41 | nPOTScale: 0 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 1 45 | spriteExtrude: 1 46 | spriteMeshType: 0 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 1 54 | spriteTessellationDetail: -1 55 | textureType: 8 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | flipbookRows: 1 59 | flipbookColumns: 1 60 | maxTextureSizeSet: 0 61 | compressionQualitySet: 0 62 | textureFormatSet: 0 63 | ignorePngGamma: 0 64 | applyGammaDecoding: 0 65 | platformSettings: 66 | - serializedVersion: 3 67 | buildTarget: DefaultTexturePlatform 68 | maxTextureSize: 2048 69 | resizeAlgorithm: 0 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | androidETC2FallbackOverride: 0 77 | forceMaximumCompressionQuality_BC6H_BC7: 0 78 | - serializedVersion: 3 79 | buildTarget: Standalone 80 | maxTextureSize: 2048 81 | resizeAlgorithm: 0 82 | textureFormat: -1 83 | textureCompression: 1 84 | compressionQuality: 50 85 | crunchedCompression: 0 86 | allowsAlphaSplitting: 0 87 | overridden: 0 88 | androidETC2FallbackOverride: 0 89 | forceMaximumCompressionQuality_BC6H_BC7: 0 90 | - serializedVersion: 3 91 | buildTarget: WebGL 92 | maxTextureSize: 2048 93 | resizeAlgorithm: 0 94 | textureFormat: -1 95 | textureCompression: 1 96 | compressionQuality: 50 97 | crunchedCompression: 0 98 | allowsAlphaSplitting: 0 99 | overridden: 0 100 | androidETC2FallbackOverride: 0 101 | forceMaximumCompressionQuality_BC6H_BC7: 0 102 | spriteSheet: 103 | serializedVersion: 2 104 | sprites: [] 105 | outline: [] 106 | physicsShape: [] 107 | bones: [] 108 | spriteID: 5e97eb03825dee720800000000000000 109 | internalID: 0 110 | vertices: [] 111 | indices: 112 | edges: [] 113 | weights: [] 114 | secondaryTextures: [] 115 | spritePackingTag: 116 | pSDRemoveMatte: 0 117 | pSDShowRemoveMatteOption: 0 118 | userData: 119 | assetBundleName: 120 | assetBundleVariant: 121 | -------------------------------------------------------------------------------- /Samples~/JSExample/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/Samples~/JSExample/.gitignore -------------------------------------------------------------------------------- /Samples~/JSExample/JSExample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using LiveKit; 3 | 4 | public class JSExample : MonoBehaviour 5 | { 6 | void Awake() 7 | { 8 | var room = new Room(); // An event will be sent to JS side 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Samples~/JSExample/JSExample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 537f77671b6668448b567f58e1882102 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/JSExample/JSExample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 608f8cf387572064a8c277af414604a6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/JSExample/JSPackage~/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /Samples~/JSExample/JSPackage~/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jspackage-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "npx webpack" 8 | }, 9 | "author": "", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "@livekit/livekit-unity": "^1.5.1" 13 | }, 14 | "devDependencies": { 15 | "ts-loader": "^9.2.7", 16 | "typescript": "^4.6.2", 17 | "webpack": "^5.70.0", 18 | "webpack-cli": "^4.9.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples~/JSExample/JSPackage~/src/index.ts: -------------------------------------------------------------------------------- 1 | import { UnityBridge, UnityEvent } from '@livekit/livekit-unity' 2 | import { Room } from 'livekit-client' 3 | 4 | var room : Room 5 | UnityBridge.instance.on(UnityEvent.RoomCreated, async (r) => { 6 | room = r; 7 | }); 8 | 9 | var muteBtn = document.getElementById('mutebtn'); 10 | muteBtn!.addEventListener('click', async () => { 11 | await room.localParticipant.setMicrophoneEnabled(false); 12 | }); -------------------------------------------------------------------------------- /Samples~/JSExample/JSPackage~/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | entry: './src/index.ts', 5 | module: { 6 | rules: [ 7 | { 8 | test: /\.tsx?$/, 9 | use: 'ts-loader', 10 | exclude: /node_modules/, 11 | }, 12 | ], 13 | }, 14 | mode: "production", 15 | resolve: { 16 | extensions: ['.tsx', '.ts', '.js'], 17 | }, 18 | output: { 19 | filename: 'index.js', 20 | path: path.resolve(__dirname, '../WebGLTemplates/LiveKitDemoJS/'), 21 | }, 22 | }; -------------------------------------------------------------------------------- /Samples~/JSExample/README.md: -------------------------------------------------------------------------------- 1 | # JSExample 2 | 3 | ## Build 4 | 5 | 1. Create a new Unity project with the LiveKit Unity SDK for WebGL (https://github.com/livekit/client-sdk-unity-web). 6 | 2. Copy the contents of this folder into the root of the `Assets` directory. 7 | 3. Build the javascript: 8 | `(cd Assets/JSPackage\~/ && npm run build)` 9 | 4. In ProjectSettings > Player > WebGL > Resolution and Presentation, select the WebGL Template named "LiveKitDemoJS." If the WebGLTemplate template isn't detected, move the WebGLTemplates folder to the assets root directory. 10 | 5. In Build Settings, select the WebGL platform. 11 | 6. In Build Settings, add the JSExample scene to the "Scenes in Build" list. 12 | 7. Build the project! -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb9b7b0eb9aca9e4090b70067d537313 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates/LiveKitDemoJS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6eea06999bc17c046990723347db9d22 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates/LiveKitDemoJS/.gitattributes: -------------------------------------------------------------------------------- 1 | index.js linguist-generated -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates/LiveKitDemoJS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Unity WebGL Player | {{{ PRODUCT_NAME }}} 7 | 8 | 9 | 10 | 11 | 12 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates/LiveKitDemoJS/index.html.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e8ed7ff2edd0a2429f86c5f0e09fa01 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/JSExample/WebGLTemplates/LiveKitDemoJS/index.js.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc97fd0503129584cbb636facccb6280 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestProject~/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/TestProject~/.DS_Store -------------------------------------------------------------------------------- /TestProject~/.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | .idea -------------------------------------------------------------------------------- /TestProject~/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 812b80b6368bc4878bf9b7086ec2cb4e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TestProject~/Assets/Scenes/SampleScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 705507994} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 2 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &705507993 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInternal: {fileID: 0} 129 | serializedVersion: 6 130 | m_Component: 131 | - component: {fileID: 705507995} 132 | - component: {fileID: 705507994} 133 | m_Layer: 0 134 | m_Name: Directional Light 135 | m_TagString: Untagged 136 | m_Icon: {fileID: 0} 137 | m_NavMeshLayer: 0 138 | m_StaticEditorFlags: 0 139 | m_IsActive: 1 140 | --- !u!108 &705507994 141 | Light: 142 | m_ObjectHideFlags: 0 143 | m_CorrespondingSourceObject: {fileID: 0} 144 | m_PrefabInternal: {fileID: 0} 145 | m_GameObject: {fileID: 705507993} 146 | m_Enabled: 1 147 | serializedVersion: 8 148 | m_Type: 1 149 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 150 | m_Intensity: 1 151 | m_Range: 10 152 | m_SpotAngle: 30 153 | m_CookieSize: 10 154 | m_Shadows: 155 | m_Type: 2 156 | m_Resolution: -1 157 | m_CustomResolution: -1 158 | m_Strength: 1 159 | m_Bias: 0.05 160 | m_NormalBias: 0.4 161 | m_NearPlane: 0.2 162 | m_Cookie: {fileID: 0} 163 | m_DrawHalo: 0 164 | m_Flare: {fileID: 0} 165 | m_RenderMode: 0 166 | m_CullingMask: 167 | serializedVersion: 2 168 | m_Bits: 4294967295 169 | m_Lightmapping: 1 170 | m_LightShadowCasterMode: 0 171 | m_AreaSize: {x: 1, y: 1} 172 | m_BounceIntensity: 1 173 | m_ColorTemperature: 6570 174 | m_UseColorTemperature: 0 175 | m_ShadowRadius: 0 176 | m_ShadowAngle: 0 177 | --- !u!4 &705507995 178 | Transform: 179 | m_ObjectHideFlags: 0 180 | m_CorrespondingSourceObject: {fileID: 0} 181 | m_PrefabInternal: {fileID: 0} 182 | m_GameObject: {fileID: 705507993} 183 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 184 | m_LocalPosition: {x: 0, y: 3, z: 0} 185 | m_LocalScale: {x: 1, y: 1, z: 1} 186 | m_Children: [] 187 | m_Father: {fileID: 0} 188 | m_RootOrder: 1 189 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 190 | --- !u!1 &963194225 191 | GameObject: 192 | m_ObjectHideFlags: 0 193 | m_CorrespondingSourceObject: {fileID: 0} 194 | m_PrefabInternal: {fileID: 0} 195 | serializedVersion: 6 196 | m_Component: 197 | - component: {fileID: 963194228} 198 | - component: {fileID: 963194227} 199 | - component: {fileID: 963194226} 200 | m_Layer: 0 201 | m_Name: Main Camera 202 | m_TagString: MainCamera 203 | m_Icon: {fileID: 0} 204 | m_NavMeshLayer: 0 205 | m_StaticEditorFlags: 0 206 | m_IsActive: 1 207 | --- !u!81 &963194226 208 | AudioListener: 209 | m_ObjectHideFlags: 0 210 | m_CorrespondingSourceObject: {fileID: 0} 211 | m_PrefabInternal: {fileID: 0} 212 | m_GameObject: {fileID: 963194225} 213 | m_Enabled: 1 214 | --- !u!20 &963194227 215 | Camera: 216 | m_ObjectHideFlags: 0 217 | m_CorrespondingSourceObject: {fileID: 0} 218 | m_PrefabInternal: {fileID: 0} 219 | m_GameObject: {fileID: 963194225} 220 | m_Enabled: 1 221 | serializedVersion: 2 222 | m_ClearFlags: 1 223 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 224 | m_projectionMatrixMode: 1 225 | m_SensorSize: {x: 36, y: 24} 226 | m_LensShift: {x: 0, y: 0} 227 | m_GateFitMode: 2 228 | m_FocalLength: 50 229 | m_NormalizedViewPortRect: 230 | serializedVersion: 2 231 | x: 0 232 | y: 0 233 | width: 1 234 | height: 1 235 | near clip plane: 0.3 236 | far clip plane: 1000 237 | field of view: 60 238 | orthographic: 0 239 | orthographic size: 5 240 | m_Depth: -1 241 | m_CullingMask: 242 | serializedVersion: 2 243 | m_Bits: 4294967295 244 | m_RenderingPath: -1 245 | m_TargetTexture: {fileID: 0} 246 | m_TargetDisplay: 0 247 | m_TargetEye: 3 248 | m_HDR: 1 249 | m_AllowMSAA: 1 250 | m_AllowDynamicResolution: 0 251 | m_ForceIntoRT: 0 252 | m_OcclusionCulling: 1 253 | m_StereoConvergence: 10 254 | m_StereoSeparation: 0.022 255 | --- !u!4 &963194228 256 | Transform: 257 | m_ObjectHideFlags: 0 258 | m_CorrespondingSourceObject: {fileID: 0} 259 | m_PrefabInternal: {fileID: 0} 260 | m_GameObject: {fileID: 963194225} 261 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 262 | m_LocalPosition: {x: 0, y: 1, z: -10} 263 | m_LocalScale: {x: 1, y: 1, z: 1} 264 | m_Children: [] 265 | m_Father: {fileID: 0} 266 | m_RootOrder: 0 267 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 268 | -------------------------------------------------------------------------------- /TestProject~/Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestProject~/Assets/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 636ccd4e1bf8c48208c6817779a35002 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/JSHandleTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace LiveKit.Tests 4 | { 5 | public class JSHandleTest 6 | { 7 | [Test] 8 | public static void TestHandleFree() 9 | { 10 | var room = new JSRef(); // There is only 1 reference to a JSHandle here 11 | var ptr = room.NativeHandle.DangerousGetHandle(); 12 | 13 | Assert.IsTrue(JSRef.Cache.ContainsKey(ptr), "Object isn't on the C# cache"); 14 | Assert.IsTrue(LKTests.BridgeData.ContainsKey(ptr.ToInt64()), "Object isn't on the JS cache"); 15 | 16 | room.Free(); // It'll only free the room NativePtr, other resources are garbage collected 17 | 18 | Assert.IsFalse(JSRef.Cache.ContainsKey(ptr), "Object is still on the C# cache"); 19 | Assert.IsFalse(LKTests.BridgeData.ContainsKey(ptr.ToInt64()), "Object is still on the JS cache"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/JSHandleTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5b678e88c53f47c99cbd24a51f1dd9b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/LKTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace LiveKit.Tests 4 | { 5 | [SetUpFixture] 6 | public class LKTests 7 | { 8 | internal static JSMap BridgeData { get; private set; } 9 | 10 | [OneTimeSetUp] 11 | public void RunBeforeAnyTests() 12 | { 13 | JSNative.PushString("Data"); 14 | BridgeData = JSRef.Acquire>(JSNative.GetProperty(JSNative.BridgeData)); 15 | } 16 | 17 | [OneTimeTearDown] 18 | public void RunAfterAnyTests() 19 | { 20 | 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/LKTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5193611006d34fc8bcbad81ddcce2ed7 3 | timeCreated: 1648909322 -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/livekit.unity.RuntimeTests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "LiveKit.BridgeTests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "LiveKitBridge" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": true, 13 | "precompiledReferences": [ 14 | "nunit.framework.dll" 15 | ], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_INCLUDE_TESTS" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /TestProject~/Assets/Tests/livekit.unity.RuntimeTests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 671a74b8a69c645d78e293e3bc1d70a9 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TestProject~/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.15.13", 4 | "com.unity.feature.development": "1.0.1", 5 | "com.unity.ide.rider": "3.0.12", 6 | "com.unity.ide.visualstudio": "2.0.14", 7 | "com.unity.ide.vscode": "1.2.5", 8 | "com.unity.test-framework": "1.1.31", 9 | "com.unity.textmeshpro": "3.0.6", 10 | "com.unity.timeline": "1.7.0-pre.2", 11 | "com.unity.ugui": "1.0.0", 12 | "com.unity.visualscripting": "1.7.5", 13 | "io.livekit.unity": "file:../../", 14 | "com.unity.modules.ai": "1.0.0", 15 | "com.unity.modules.androidjni": "1.0.0", 16 | "com.unity.modules.animation": "1.0.0", 17 | "com.unity.modules.assetbundle": "1.0.0", 18 | "com.unity.modules.audio": "1.0.0", 19 | "com.unity.modules.cloth": "1.0.0", 20 | "com.unity.modules.director": "1.0.0", 21 | "com.unity.modules.imageconversion": "1.0.0", 22 | "com.unity.modules.imgui": "1.0.0", 23 | "com.unity.modules.jsonserialize": "1.0.0", 24 | "com.unity.modules.particlesystem": "1.0.0", 25 | "com.unity.modules.physics": "1.0.0", 26 | "com.unity.modules.physics2d": "1.0.0", 27 | "com.unity.modules.screencapture": "1.0.0", 28 | "com.unity.modules.terrain": "1.0.0", 29 | "com.unity.modules.terrainphysics": "1.0.0", 30 | "com.unity.modules.tilemap": "1.0.0", 31 | "com.unity.modules.ui": "1.0.0", 32 | "com.unity.modules.uielements": "1.0.0", 33 | "com.unity.modules.umbra": "1.0.0", 34 | "com.unity.modules.unityanalytics": "1.0.0", 35 | "com.unity.modules.unitywebrequest": "1.0.0", 36 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 37 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 38 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 39 | "com.unity.modules.unitywebrequestwww": "1.0.0", 40 | "com.unity.modules.vehicles": "1.0.0", 41 | "com.unity.modules.video": "1.0.0", 42 | "com.unity.modules.vr": "1.0.0", 43 | "com.unity.modules.wind": "1.0.0", 44 | "com.unity.modules.xr": "1.0.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 31 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_Modified: 0 32 | m_ErrorMessage: 33 | m_UserModificationsInstanceId: -830 34 | m_OriginalInstanceId: -832 35 | m_LoadAssets: 0 36 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "m_Name": "Settings", 3 | "m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json", 4 | "m_Dictionary": { 5 | "m_DictionaryValues": [] 6 | } 7 | } -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.3.1f1 2 | m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835) 3 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/RiderScriptEditorPersistedState.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState 15 | lastWriteTicks: -8585497619091841462 16 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /TestProject~/ProjectSettings/boot.config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/livekit/client-sdk-unity-web/05ccb358334403b46678e6bba6f354b642dd74bf/TestProject~/ProjectSettings/boot.config -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "io.livekit.unity", 3 | "version": "2.0.1", 4 | "displayName": "LiveKit WebGL SDK", 5 | "description": "LiveKit Unity Bridge for WebGL", 6 | "unity": "2021.3", 7 | "author": { 8 | "name": "Théo Monnom", 9 | "email": "theo.monnom@outlook.com" 10 | }, 11 | "samples": [ 12 | { 13 | "displayName": "Example", 14 | "description": "LiveKit sample", 15 | "path": "Samples~" 16 | } 17 | ], 18 | "type": "library", 19 | "dependencies": { 20 | "com.unity.nuget.newtonsoft-json": "2.0.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55aea0363c56ca240bbb275470acda75 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------