2023.3: Building Unity Games on Windows
The Unity Game Engine makes building your game nearly a trivial task and in this write-up we’ll see what essential settings are needed in order to compile a game to an executable binary for your system. For the sake of this article, I’ll be compiling to Windows.
We’ll need to access the “Build Settings” which for Windows is located under File > Build Settings...
or Ctrl+Shift+B
. This will bring up the Build Settings window (by default, you might have your build settings docked within the editor). Next, click on the “Windows, Mac, Linux” option under the “Platform” list.
On the “Target Platform” the platform you are on will be the one selected but you can click on the dropdown and select “Windows” or “Linux” for example if you’re on a mac and have your environment configured to compile for those systems already, as Unity will use what you have your compiler configurations for those target systems. I’m on a Windows machine so I’m going to target Windows for the platform.
Before we click on Build, we need to do a couple more things. Firstly, we need to make sure we’ve selected the Scenes in the game. For my game, I’ve got two scenes — One for the game’s Main Menu and the second is the Game itself. With those both checked we can now look at a couple of settings in the “Player Settings…”
In the Player Settings interface, there is a lot to configure and you’re going to want to read the Unity Docs in detail to get all that takes place in here. For example, depending on the type of post processing you use, you may need to go into “Other Settings > Rendering” and select an appropriate “Color Space*” value. For my post processing effects, I had to select “Linear”. And when I write up about how to publish your game on the web, we’ll have to look at the WebGL Publish Settings.
So, back to the main point…Under the Player Settings you can change your Company Name, product name and version number — which I have left as the default values in the screenshot above. On the “desktop” icon tab (Settings for Windows, Mac, Linux”) we want to change a couple of things under the “Resolution and Presentation” settings. For the “Fullscreen Mode” we want to select “Windowed” since we don’t have a way for the player to quit the game yet…don’t worry, we’ll get to that shortly. Once you select “Windowed” you’ll want to select what your Default Screen Width and Height values will be for your game. For mine, I left it at 1920 for the width and 1080 for the height. I also deselected the “Allow Fullscreen Switch*” option.
With those changes made, we’re ready to close the “Player Settings” window and click on the “Build” button. The first time you click on this you’ll need to select what the output folder will be. I used “Windows Playable Build” as my folder name.
Once the build completes you should have your game’s .exe file in the folder you selected as the output folder. Double clicking my game opened it up and I’m playing!
Up Next:
We’ll get into the weeds on how to build for WebGL