Skip to main content

Unity

Welcome to your fresh Robo.js project!

Build, deploy, and maintain your Discord activities with ease. With Robo.js as your guide, you'll experience a seamless, file-based setup, an integrated database, TypeScript support, and a multitude of plugin-powered skills to unlock along the way.

Ready to embark on this adventure?

Getting Started​

Create a project with this template, replacing <project-name> with your desired name:

Terminal
npx create-robo <project-name> --template discord-activities/unity

Then navigate into your project directory:

Terminal
cd <project-name>

Run development mode:

Terminal
npm run dev

Connecting your Unity game​

To import your Unity game inside of your Robo project follow these steps:

In your Unity project install dissonity:

  1. Go to Window > Package Manager > Add package from git URL
  2. Install the package from https://github.com/Furnyr/Dissonity.git?path=/unity
  3. Right click in the hierarchy, Dissonity > Discord Bridge

Once you have done these steps follow these next ones

  1. Click on file (top left corner)
  2. Go to build settings
  3. In platform, choose WebGL
  4. Click on build and go into your Robo project and select the public folder.
  5. Once the game has been built head over into the index.html file into your public folder
  6. Go down the file and introduce a new variable called unityInstance
  7. Go down again until you see createUnityInstance in the then change the paremeter name to ui then in the scope write unityInstance = ui
  8. Tada ! you have successfully built a Unity Project with Robo all that's left to do is enjoy making your game.

Notes: If you decide to make a special folder for your project. ex: public/myfolder/mygamefiles please go to src/app/Activity.tsx and change

<iframe id="dissonity-child" src=".proxy/index.html" height="100vh" width="100vw" scrolling="no"></iframe>

to

<iframe id="dissonity-child" src=".proxy/myfolder/index.html" height="100vh" width="100vw" scrolling="no"></iframe>

To get the best of Dissonity please refer to their docs!

Notes: A free Cloudflare tunnel is included for easy testing. You can copy and paste it into activity's URL mapping to test things out.

➞ πŸ“š Documentation: Exploring Different Run Modes

➞ πŸš€ Documentation: Deploying for Free with 24/7 Uptime

Your Robo refreshes with every change. πŸ”„

A free Cloudflare tunnel is included for easy testing. You can copy and paste it into activity's URL mapping to test things out.

Psst... Check out the deployment instructions to keep your Robo online 24/7.

App Development ️​

You can find your client-side code in the /src/app folder. This is where you can build your web app using React, Vue, or any other front-end framework.

Things are powered by Vite under the hood, so you get the latest ES modules, hot module reloading, and more! ⚑

Try editing the main file to get started! (Activity.tsx if you're using React)

➞ πŸ“š Documentation: App development

Authenticating​

The React template makes it easy to authenticate your activity with Discord. The <DiscordProvider> components in App.tsx accepts authenticate and scope props.

<DiscordContextProvider authenticate scope={['identify', 'guilds']}>
<Activity />
</DiscordContextProvider>

You can then get the SDK and other goodies from the useDiscordSdk hook!

Backend Development ️​

Your server-side code is located in the /src/api folder. This is where you can build your API, webhooks, and other fancy server-side features.

This backend is powered by the Server Plugin - a powerful Robo plugin that creates an manages a Node http server for you. If you install Fastify, the server will automatically switch to it for better performance!

Everything Robo is file-based, so you can create new routes by making new files in the /src/api directory. The file's name becomes the route's path. For example, let's try making a new route at /health by creating a new file named health.js:

export default () => {
return { status: 'ok' }
}

Easy, right? Check out the Server Plugin documentation for more info!

Folder Structure​

While the api and app folders are reserved for your server and client-side code, you are free to create anything else in the /src directory!

Folders only become reserved when you install a plugin that uses them. For example, bot functionality uses the commands and events folders.

Plugins​

This Robo boasts an intuitive plugin system that grants new capabilities instantly!

Terminal
npx robo add @robojs/ai

Swap out @robojs/ai with your chosen plugin's package name

With that, your Robo automatically equips itself with all the features the plugin offers. Want to revert? Simply use robo remove to uninstall any plugin.

➞ πŸ“š Documentation: Installing plugins

Crafting something unique in your Robo project? You can turn your innovations into plugins, be it specific functionalities or your entire Robo. Share your genius with the world!

➞ πŸ“š Documentation: Creating plugins

Deployment​

Run the deploy command to automatically deploy to RoboPlay once you're ready to keep your robo online 24/7.

Terminal
npm run deploy

➞ πŸš€ RoboPlay: Hosting your Robo

You can also self-host your robo anywhere that supports Node. Just make sure to run build followed by start:

Terminal
npm run build
npm start

Learn More​

Robo.js Logo

MIT Β© 2024 Robo.js By WavePlay