Setting up the project locally is similar to any other Unity project:
- Ensure you have Unity 2022.3.23f1 installed.
- Install NodeJS on your system.
- Fork the repository and clone it to your local drive.
- To build the plugin, run these commands in your terminal:
This command will install the
cd Assets/Playroomkit npm installupstream.sdkand its dependencies. It also creates aPlayroomfolder insideAssets/Plugins, containing two files: a.JSLIBfile and a.JSPREfile. - Complete your setup by running
npm installwhenever changes are made toPlayroomkit/src/index.js.
- User-facing Documentation: https://docs.joinplayroom.com/usage/unity
- Join our developer chatroom: https://discord.gg/uDHxeRYhRe
- Email our founder: tabish@joinplayroom.com
Read more about the PlayroomKit Unity integration and the design behind it.
The Playroom's JavaScript SDK (hereafter referred to as the "JavaScript SDK") is the foundation of this Unity package. For detailed information, visit this changelog.
To implement a new feature available in the upstream SDK:
- Create
Internalfunctions in theindex.jsfile. - Develop
C#bindings for these functions in theHeaders.csfile. - Define methods within the
IInteropinterface and implement them in thePlayroomKitInteropclass. These are necessary for running tests. - Begin implementing methods for the three modes/services: LocalPlayroomService, BrowserPlayroomService, and BuildPlayroomService (all extended from the
IPlayroomBaseinterface). - Implement these functions across all services based on their specific requirements.
- The unified function is already handled, so you only need to create a method in
Playroomkit.csthat callsCheckPlayRoomInitialized()and delegates to the implemented methods in each service.
The process for implementing fixes from the upstream SDK mirrors other feature implementations, typically done within the index.js file.
This package follows this folder structure:
PlayroomKit
├── dependencies/
├── Editor/
├── Examples/
├── modules/
├── node_modules/
├── Prefabs/
├── src/
└── Tests/
└── package.json
└── package-lock.json
└── Playroom.asmdef
└── PlayroomKit.cs
└── vite.config.js
The package also includes a custom WebGL template for Discord activities located in Assets/WebGLTemplates.
Playroomkit comes with many modules which help with speeding up development. Unity SDK builds on top of that and adds its own modules such as MockMode. The folder structure is something like this:
modules
├── Helpers/
├── Interfaces/
├── MockMode/
├── Options/
├── Player/
└── RPC/
├── Headers
├── PlayroomBuildService
└── PlayroomkitDevManager
- Helpers: Includes utilities such as CallbackManager, CommandManager, and a Helpers class used for serializing and deserializing data.
- Interfaces: Contains all of the base interfaces from which other classes inherit.
- MockMode: Holds files for editor-only modes, including Browser and Local mock modes.
- Options: Contains classes for settings and options related to different modules, such as InitOptions.
- Player: Contains classes related to Player features and functionality.
- RPC: Contains classes for implementing Remote Procedure Calls (RPC) related features.
- Headers.cs: Contains method declarations which are implemented in
src/index.src - PlayroomBuildService.cs: Build mode of playroomkit which only runs in the compiled game.
- PlayroomkitDevManager.cs: Manager script for choosing between local and browser mockmode, this is used in the
PlayroomMockManagerprefab.
Tests are located in the Playroomkit/Tests folder and are currently editor-only. Install Unity Test Runner to execute tests via the Window/General/Test Runner menu.