Beginner s&box Tutorials: Chapter 1 - Setting up your Development Environment

This tutorial will get you set up with a development environment for s&box quickly and easily! We will set up our IDE and learn how to open the s&box solution.

Beginner s&box Tutorials: Chapter 1 - Setting up your Development Environment

This tutorial will get you set up with a development environment for s&box quickly and easily! We will set up our IDE and learn how to open the s&box solution.

Choosing an IDE

IDE stands for integrated development environment. It is essentially a program that helps you write code by providing lots of extra features for you all in one spot. s&box uses the C# programming language. The two most popular IDEs for C# are Microsoft's Visual Studio and JetBrains' Rider. Furthermore, you can use Visual Studio Code, which is a code editor that has plugins that support C#. If you already have a preference, we recommend using what you're comfortable with. But for this tutorial we will focus on Visual Studio 2022, which is free to use and easy to set up.

Download Visual Studio 2022

You can download Visual Studio 2022 Community here. When it's done, open it up. It will install the Visual Studio Installer app on your computer, which can be used to manage your Visual Studio and workload installations.

The Visual Studio Installer.

As the above image shows, you want to select .NET desktop development. Select the optional checkboxes (on the right). You can select more of the optional features if you desire. You can also customize the installation location. We recommend installing Visual Studio on the same Disk Drive that you have s&box installed. Currently, there are some bugs with s&box's hotloading feature where installing the IDE on a different drive than s&box leads to failures in hotloading of your code.

When you're ready to install, click the Install button. Visual Studio will automatically install all the dependencies you need to start developing in C#. After the download is finished, you may be prompted to sign in with a Microsoft account. After you do this, you'll be greeted with the Visual Studio 2022 startup screen. You can close this for now - we will be opening Visual Studio another way. Furthermore, you can close the Visual Studio installer as well.

Opening the s&box.sln file

Now that Visual Studio is installed, we can open the s&box.sln file. The .sln filetype stands for solution, representing a Visual Studio solution. A solution represents a collection of relevant projects. Open your Steam library, right click on s&box, and go to Manage > Browse local files.

I, too, was a victim of New World addiction.

This is a great time to open s&box for the first time if you haven't already. You can open sbox.exe to open the game. sbox-dev.exe will open the Source 2 tools such as Hammer, Modeldoc, and more. The s&box.sln file is generated anew each time you open s&box. Any time you want to develop for s&box, you must open the s&box.sln file, or you won't be able to use autocomplete/IntelliSense features!

After opening your game, go ahead and double click s&box.sln. Visual Studio should open.

The Visual Studio Solution Explorer appears on the side of your screen.

Currently, your window might look a little empty. The important thing to take note of right now is the Solution Explorer. You should see a few top level projects - base and menu. Base contains the Core s&box API that you will use to develop a s&box gamemode. Menu is the code for the s&box main menu, and also contains a useful package called UITests which provides plenty of neat examples for using different UI elements in s&box. You can look through these as much as you want.

A sample of classes and files available from base and menu projects.

Visual Studio Extensions

The Manage Extensions menu.

A popular feature of Visual Studio is its Extensions. You can open the Extensions menu by clicking Extensions > Manage Extensions in the top menu bar. Here, you can download a wide variety of extensions that make your experience developing in Visual Studio more productive or fun. Furthermore, you can download themes for the IDE here, which will change the appearance of Visual Studio.

What's Next?

If you've completed this tutorial, you can move on to Chapter 2 - Creating your First Gamemode.

Feedback

If you have feedback, questions, or comments, feel free to shoot me a DM on twitter @sboxcommunity! We will try to keep these tutorials as up-to-date as possible. s&box is still in early access and constantly evolving, meaning things can become outdated very quickly.