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 f791e06..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,13 +108,13 @@ 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. -### 4. Exporting to WebGL +### Export your game To bring your game to the world, you must build! Configure your Build settings to our optimal settings. @@ -124,6 +131,8 @@ 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. + + ## Updating from a previous version Update PlayroomKit for Unity to get the latest features and fixes. We recommend doing the following: @@ -131,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. @@ -264,34 +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. -## Examples - -Check out some simple and advanced use cases! - -### Simple Example +### PlayroomKit Console -Use `WASD` or `Arrow keys` to move the player around. The player's position is synced with other players in real-time. +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. -Code for this example can be found [here](https://github.com/asadm/playroom-docs/tree/main/examples/unity-hello-world). +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`. - +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. -### Beanz: Discord Activity Demo +The PlayroomKit console also allows developers to manage room configurations like retrieving room codes and customizing room settings. -Once built, this demo works on both WebGL in the browser, and in [Discord Activities](/components/discord). +## Comparing SDK's -Code for this example can be found [here](https://github.com/asadm/playroom-unity/tree/main/Assets/PlayroomKit/Examples/discord-activity). +A comparison of the types of components our JS and Unity `playroomkit` SDK's are currently supporting: - - - -## 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 diff --git a/pages/usage/unity/_meta.json b/pages/usage/unity/_meta.json new file mode 100644 index 0000000..700fc41 --- /dev/null +++ b/pages/usage/unity/_meta.json @@ -0,0 +1,4 @@ +{ + "simple": "Simple Example", + "advanced": "Advanced Example" +} diff --git a/pages/usage/unity/advanced.mdx b/pages/usage/unity/advanced.mdx new file mode 100644 index 0000000..1b77718 --- /dev/null +++ b/pages/usage/unity/advanced.mdx @@ -0,0 +1,15 @@ +### Beanz: Discord Activity Demo + +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). + +