From f07419911f87fe9c0fef3cca2a56ad1346158b6c Mon Sep 17 00:00:00 2001 From: Talal Ahmed Khan <93150072+Deletus-Fast@users.noreply.github.com> Date: Wed, 5 Mar 2025 00:13:18 +0500 Subject: [PATCH 1/4] Update unity.mdx --- pages/usage/unity.mdx | 47 +++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/pages/usage/unity.mdx b/pages/usage/unity.mdx index f791e06..ff7fd58 100644 --- a/pages/usage/unity.mdx +++ b/pages/usage/unity.mdx @@ -107,23 +107,6 @@ Use [`PlayroomKit.SetState`](/apidocs/unity#setstatestring-key-t-value-bool-reli See the [API reference](/apidocs/unity) for more information. -### 4. Exporting to WebGL - -To bring your game to the world, you must build! Configure your Build settings to our optimal settings. - -1. Go to `File > Build Settings` and select `WebGL` as the platform. -2. In Player Settings: - - Set `Resolution and Presentation > Run In Background` to `true`. - - Choose your desired template (Choose **DiscordTemplate** if you want to publish to Discord Activities). - - Set `Compression Format` to `None` under `Publishing Settings` (this is to make sure the build works with the [Playroom Portal](https://dev.joinplayroom.com)). -3. Build your game. -4. To test the build locally in your browser, run `python -m http.server` in the resultant build folder. We also recommend using [Servez](https://greggman.github.io/servez/), a simple web server solution with a nice interface. - -
- - -Do note that **PlayroomKit for Unity** only works with WebGL builds. - ## Updating from a previous version Update PlayroomKit for Unity to get the latest features and fixes. We recommend doing the following: @@ -276,6 +259,23 @@ Code for this example can be found [here](https://github.com/asadm/playroom-docs +### Exporting to WebGL + +To bring your game to the world, you must build! Configure your Build settings to our optimal settings. + +1. Go to `File > Build Settings` and select `WebGL` as the platform. +2. In Player Settings: + - Set `Resolution and Presentation > Run In Background` to `true`. + - Choose your desired template (Choose **DiscordTemplate** if you want to publish to Discord Activities). + - Set `Compression Format` to `None` under `Publishing Settings` (this is to make sure the build works with the [Playroom Portal](https://dev.joinplayroom.com)). +3. Build your game. +4. To test the build locally in your browser, run `python -m http.server` in the resultant build folder. We also recommend using [Servez](https://greggman.github.io/servez/), a simple web server solution with a nice interface. + +
+ + +Do note that **PlayroomKit for Unity** only works with WebGL builds. + ### Beanz: Discord Activity Demo Once built, this demo works on both WebGL in the browser, and in [Discord Activities](/components/discord). @@ -404,15 +404,4 @@ These excerpts come from conversations with an active Discord member, **Guilherm Remember that both mock modes in the Unity Editor approximate the final WebGL build. Some differences may occur due to the underlying C++ and JS compilation in the web environment. - - -## Aurea NetLayer: a higher level API for Unity - -**GuilhermeAlanJohann** from our Discord community has created a [higher level plugin](https://gitlab.com/PCista/com.aurea.packages.netlayer) for Unity that makes it easier to use Playroom with Unity. - -#### Features -- Sync position and rotations of objects over the network (supports interpolation) -- Different object authorities (Host and LocalPlayer) -- Spawn/Unspawn objects over the network -- Send Messages to others (including or excluding yourself) -- RPC (...kind of). It uses Unity message system. \ No newline at end of file + \ No newline at end of file From bebc974ce22ddf0a6fd9428f4d34cb2ed1cd91d8 Mon Sep 17 00:00:00 2001 From: Talal Ahmed Khan <93150072+Deletus-Fast@users.noreply.github.com> Date: Wed, 5 Mar 2025 00:17:34 +0500 Subject: [PATCH 2/4] Update unity.mdx --- pages/usage/unity.mdx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pages/usage/unity.mdx b/pages/usage/unity.mdx index ff7fd58..9efe02e 100644 --- a/pages/usage/unity.mdx +++ b/pages/usage/unity.mdx @@ -247,18 +247,6 @@ This feature uses [ParrelSync](https://github.com/VeriorPies/ParrelSync) Unity E By utilizing both Mock Modes and the Multiple Player testing feature, you can thoroughly test your game's multiplayer functionality and performance within the Unity environment before proceeding to a full WebGL build. -## Examples - -Check out some simple and advanced use cases! - -### Simple Example - -Use `WASD` or `Arrow keys` to move the player around. The player's position is synced with other players in real-time. - -Code for this example can be found [here](https://github.com/asadm/playroom-docs/tree/main/examples/unity-hello-world). - - - ### Exporting to WebGL To bring your game to the world, you must build! Configure your Build settings to our optimal settings. @@ -276,6 +264,18 @@ To bring your game to the world, you must build! Configure your Build settings t Do note that **PlayroomKit for Unity** only works with WebGL builds. +## Examples + +Check out some simple and advanced use cases! + +### Simple Example + +Use `WASD` or `Arrow keys` to move the player around. The player's position is synced with other players in real-time. + +Code for this example can be found [here](https://github.com/asadm/playroom-docs/tree/main/examples/unity-hello-world). + + + ### Beanz: Discord Activity Demo Once built, this demo works on both WebGL in the browser, and in [Discord Activities](/components/discord). From 5ac9dd1b7a3761857f6dad0e47c583f2c9c4434a Mon Sep 17 00:00:00 2001 From: Talal Ahmed Khan <93150072+Deletus-Fast@users.noreply.github.com> Date: Wed, 5 Mar 2025 00:21:51 +0500 Subject: [PATCH 3/4] Update unity.mdx --- pages/usage/unity.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/usage/unity.mdx b/pages/usage/unity.mdx index 9efe02e..e35bd8d 100644 --- a/pages/usage/unity.mdx +++ b/pages/usage/unity.mdx @@ -247,6 +247,8 @@ This feature uses [ParrelSync](https://github.com/VeriorPies/ParrelSync) Unity E By utilizing both Mock Modes and the Multiple Player testing feature, you can thoroughly test your game's multiplayer functionality and performance within the Unity environment before proceeding to a full WebGL build. +## Exporting + ### Exporting to WebGL To bring your game to the world, you must build! Configure your Build settings to our optimal settings. From 2de7b16e27db836af32fb4d10b416f443bfdf88a Mon Sep 17 00:00:00 2001 From: Talal Ahmed Khan <93150072+Deletus-Fast@users.noreply.github.com> Date: Wed, 12 Mar 2025 00:32:55 +0500 Subject: [PATCH 4/4] Changes to usage/unity --- package-lock.json | 16 + package.json | 1 + pages/usage/unity.mdx | 152 +- pages/usage/unity/_meta.json | 4 + pages/usage/unity/advanced.mdx | 15 + pages/usage/unity/simple.mdx | 8 + public/demos/unity/Build/2dexample.data | Bin 0 -> 5433866 bytes .../demos/unity/Build/2dexample.framework.js | 66271 ++++++++++++++++ public/demos/unity/Build/2dexample.loader.js | 1271 + public/demos/unity/Build/2dexample.wasm | Bin 0 -> 41530772 bytes public/demos/unity/Build/unity.data | Bin 2582025 -> 0 bytes public/demos/unity/Build/unity.framework.js | 22 - public/demos/unity/Build/unity.loader.js | 1 - public/demos/unity/Build/unity.wasm | Bin 11007220 -> 0 bytes .../TemplateData/icons/unity-logo-dark.png | Bin 5615 -> 0 bytes .../TemplateData/icons/unity-logo-light.png | Bin 5589 -> 0 bytes public/demos/unity/TemplateData/style.css | 35 +- public/demos/unity/index.html | 181 +- public/icons/square-code.svg | 1 + public/images/Unity-Advanced.png | Bin 0 -> 46034 bytes public/images/Unity-Advanced.webp | Bin 0 -> 46268 bytes public/images/Unity-Simple.png | Bin 0 -> 29766 bytes public/images/Unity-Simple.webp | Bin 0 -> 12520 bytes 23 files changed, 67827 insertions(+), 151 deletions(-) create mode 100644 pages/usage/unity/_meta.json create mode 100644 pages/usage/unity/advanced.mdx create mode 100644 pages/usage/unity/simple.mdx create mode 100644 public/demos/unity/Build/2dexample.data create mode 100644 public/demos/unity/Build/2dexample.framework.js create mode 100644 public/demos/unity/Build/2dexample.loader.js create mode 100644 public/demos/unity/Build/2dexample.wasm delete mode 100644 public/demos/unity/Build/unity.data delete mode 100644 public/demos/unity/Build/unity.framework.js delete mode 100644 public/demos/unity/Build/unity.loader.js delete mode 100644 public/demos/unity/Build/unity.wasm delete mode 100644 public/demos/unity/TemplateData/icons/unity-logo-dark.png delete mode 100644 public/demos/unity/TemplateData/icons/unity-logo-light.png create mode 100644 public/icons/square-code.svg create mode 100644 public/images/Unity-Advanced.png create mode 100644 public/images/Unity-Advanced.webp create mode 100644 public/images/Unity-Simple.png create mode 100644 public/images/Unity-Simple.webp diff --git a/package-lock.json b/package-lock.json index 4a06ecc..6e33dd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@vercel/og": "^0.6.2", + "lucide-react": "^0.479.0", "mixpanel-browser": "^2.47.0", "next": "^13.0.6", "nextra": "^2.11.0", @@ -2227,6 +2228,15 @@ "yallist": "^2.1.2" } }, + "node_modules/lucide-react": { + "version": "0.479.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.479.0.tgz", + "integrity": "sha512-aBhNnveRhorBOK7uA4gDjgaf+YlHMdMhQ/3cupk6exM10hWlEU+2QtWYOfhXhjAsmdb6LeKR+NZnow4UxRRiTQ==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/markdown-extensions": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz", @@ -6126,6 +6136,12 @@ "yallist": "^2.1.2" } }, + "lucide-react": { + "version": "0.479.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.479.0.tgz", + "integrity": "sha512-aBhNnveRhorBOK7uA4gDjgaf+YlHMdMhQ/3cupk6exM10hWlEU+2QtWYOfhXhjAsmdb6LeKR+NZnow4UxRRiTQ==", + "requires": {} + }, "markdown-extensions": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz", diff --git a/package.json b/package.json index 94d797c..3bf7839 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@vercel/og": "^0.6.2", + "lucide-react": "^0.479.0", "mixpanel-browser": "^2.47.0", "next": "^13.0.6", "nextra": "^2.11.0", diff --git a/pages/usage/unity.mdx b/pages/usage/unity.mdx index e35bd8d..6047f83 100644 --- a/pages/usage/unity.mdx +++ b/pages/usage/unity.mdx @@ -15,6 +15,7 @@ import Preview from '../../components/preview' import Badge from '../../components/badge' import Image from 'next/image' import { Tabs, Tab } from 'nextra/components' +import { Steps } from 'nextra/components' The Unity SDK currently only supports **Unity Web.** This is an experimental technology. @@ -24,13 +25,16 @@ Unity is the most popular game engine, it's also a great way to make web games t Playroom Kit complements Unity by simplifying the development of multiplayer games and interactive web-based applications. +Make sure to check out the Playroom Kit Unity SDK [Changelog](https://github.com/asadm/playroom-unity/releases) to get to know about anything new in the latest version! + ## Getting started ### Video Tutorial -### 1. Install the SDK + +### Install the SDK 1. Download `playroomkit.unitypackage` from the [releases page](https://github.com/asadm/playroom-unity/releases) (download `playroomkit.unitypackage` file). 2. Drag the package into your Unity project and import all files. @@ -43,7 +47,7 @@ npm install This will install the required dependencies for the SDK. -### 2. Initialize Playroom +### Initialize Playroom = v1.0.0 (latest)', 'Below 1.0.0']}> @@ -58,10 +62,13 @@ Then, in your game's `Start` method, call [`InsertCoin`](/apidocs/unity#insertco using Playroom; // ... -private PlayroomKit _playroomKit = new(); +private PlayroomKit _playroomKit; // ... void Start() { + // create a new instance before calling InsertCoin + _playroomKit = new(); + _playroomKit.InsertCoin(new InitOptions() { maxPlayersPerRoom = 2, @@ -101,12 +108,31 @@ void Start() { Now you can use Playroom throughout your game! -### 3. Manage game state +### Manage game state -Use [`PlayroomKit.SetState`](/apidocs/unity#setstatestring-key-t-value-bool-reliable--false-void) and [`PlayroomKit.GetState`](/apidocs/unity#getstatetstring-key-t) to handle game state. These automatically sync with other players. +PlayroomKit provides a robust state synchronization system through the [`PlayroomKit.SetState`](/apidocs/unity#setstatestring-key-t-value-bool-reliable--false-void) and [`PlayroomKit.GetState`](/apidocs/unity#getstatetstring-key-t) methods. These methods are used to handle game states and automatically sync with other players. See the [API reference](/apidocs/unity) for more information. +### Export your game + +To bring your game to the world, you must build! Configure your Build settings to our optimal settings. + +1. Go to `File > Build Settings` and select `WebGL` as the platform. +2. In Player Settings: + - Set `Resolution and Presentation > Run In Background` to `true`. + - Choose your desired template (Choose **DiscordTemplate** if you want to publish to Discord Activities). + - Set `Compression Format` to `None` under `Publishing Settings` (this is to make sure the build works with the [Playroom Portal](https://dev.joinplayroom.com)). +3. Build your game. +4. To test the build locally in your browser, run `python -m http.server` in the resultant build folder. We also recommend using [Servez](https://greggman.github.io/servez/), a simple web server solution with a nice interface. + +
+ + +Do note that **PlayroomKit for Unity** only works with WebGL builds. + +
+ ## Updating from a previous version Update PlayroomKit for Unity to get the latest features and fixes. We recommend doing the following: @@ -114,6 +140,55 @@ Update PlayroomKit for Unity to get the latest features and fixes. We recommend 2. Delete all `node_modules` folders from your previous installation 3. Add the latest plugin (See [Installation instructions](#1-install-the-sdk)). You **must** re-run `npm install` and get fresh packages. +## Examples + +Check out some simple and advanced use cases! + +import { Cards, Card } from 'nextra/components' +import { SquareCode } from 'lucide-react'; + + + } + title="Simple Example" + href="/usage/unity/simple" + style={{ + backgroundImage: "url(/images/Unity-Simple.png)", + backgroundSize: 'contain', + backgroundPosition: 'center', + color: 'white', + + padding: '20px', + height: '210px', + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + filter: 'contrast(1) brightness(0.8)', + }} + /> + + } + title="Advanced Example" + href="/usage/unity/advanced" + style={{ + backgroundImage: "url(/images/Unity-Advanced.png)", + backgroundSize: 'contain', + backgroundPosition: 'center', + color: 'white', + + padding: '20px', + height: '210px', + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + filter: 'contrast(1) brightness(0.8)', + }} + /> + + ## Testing your games PlayroomKit for Unity ships with some helpful features to make multiplayer game dev easier. @@ -247,53 +322,42 @@ This feature uses [ParrelSync](https://github.com/VeriorPies/ParrelSync) Unity E By utilizing both Mock Modes and the Multiple Player testing feature, you can thoroughly test your game's multiplayer functionality and performance within the Unity environment before proceeding to a full WebGL build. -## Exporting - -### Exporting to WebGL - -To bring your game to the world, you must build! Configure your Build settings to our optimal settings. - -1. Go to `File > Build Settings` and select `WebGL` as the platform. -2. In Player Settings: - - Set `Resolution and Presentation > Run In Background` to `true`. - - Choose your desired template (Choose **DiscordTemplate** if you want to publish to Discord Activities). - - Set `Compression Format` to `None` under `Publishing Settings` (this is to make sure the build works with the [Playroom Portal](https://dev.joinplayroom.com)). -3. Build your game. -4. To test the build locally in your browser, run `python -m http.server` in the resultant build folder. We also recommend using [Servez](https://greggman.github.io/servez/), a simple web server solution with a nice interface. - -
- - -Do note that **PlayroomKit for Unity** only works with WebGL builds. - -## Examples +### PlayroomKit Console -Check out some simple and advanced use cases! +The `Playroom Console`, inspired by Valve's CSGO console, is a powerful Unity-based utility designed to accelerate multiplayer development with PlayroomKit. The console allows developers to rapidly `test`, `debug` and `implement` directly within the running game. -### Simple Example +The PlayroomKit Console offers a comprehensive command set, enabling developers to interact with essential PlayroomKit API functions. This includes: +- **InsertCoin:** Facilitating game initialization and setup. +- **Player state management:** Modifying and inspecting player-specific data with commands like `PlayerGetProfile`, `PlayerSetProfile`, `WaitForPlayerState`, and `PlayerResetState`. +- **Matchmaking:** Simulating and testing matchmaking scenarios with commands like `RpcRegister` and `RpcCall`. +- **Event handling:** Triggering and observing game events with commands like `MyPlayer.Kick`, and `MyPlayer.Quit`. -Use `WASD` or `Arrow keys` to move the player around. The player's position is synced with other players in real-time. +Leveraging `PowerConsole`, a Unity-based runtime console for enhanced debugging, the PlayroomKit Console provides detailed, real-time logging of command execution and game state changes. This feature allows developers to Track the execution flow of commands, identify and diagnose issues promptly, and analyze game state transitions for debugging purposes. -Code for this example can be found [here](https://github.com/asadm/playroom-docs/tree/main/examples/unity-hello-world). +The PlayroomKit console also allows developers to manage room configurations like retrieving room codes and customizing room settings. - +## Comparing SDK's -### Beanz: Discord Activity Demo +A comparison of the types of components our JS and Unity `playroomkit` SDK's are currently supporting: -Once built, this demo works on both WebGL in the browser, and in [Discord Activities](/components/discord). - -Code for this example can be found [here](https://github.com/asadm/playroom-unity/tree/main/Assets/PlayroomKit/Examples/discord-activity). - -