Reader small image

You're reading from  Creating an RTS Game in Unity 2023

Product typeBook
Published inOct 2023
Reading LevelN/a
PublisherPackt
ISBN-139781804613245
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Bruno Cicanci
Bruno Cicanci
author image
Bruno Cicanci

Bruno Cicanci is a software engineer and game developer with professional experience on different technologies and platforms. Since 2009, Bruno helped to develop and publish many games, mainly using Unity for mobile devices. He writes about game development on his personal blog, which led him to present many talks at universities and events. Bruno holds a Computer Science BS. Degree and a specialization and Game Production and Programming. In the last decade, he worked at prestigious game studios such as Glu Mobile, Electronic Arts, and Aquiris. He is currently developing games and reusable technologies at Ubisoft. Originally from Sao Paulo, Brazil, Bruno currently resides in London, UK with his wife and two adorable cats.
Read more about Bruno Cicanci

Right arrow

Exporting and Expanding Your Game

It is fun to develop our own games and play them in the Unity Editor, but it is even more fun to share what we have built with other people so they can also play the games we have developed.

In this chapter, we are going to see how to manually export the game for desktop platforms, such as Windows and macOS, with custom build options, and also how to automate this process using a custom build script that will export different builds depending on our build options.

You will also learn how to expand the game by adding background music to our levels and sound effects to give the players feedback on their actions, as well as how to add more content, such as new units, enemies, objectives, and levels – everything you need to make Dragoncraft your own game, using the tools and features we developed through the book.

So, in this chapter, we will cover the following topics:

  • Exporting Dragoncraft for Desktop
  • Creating a build system...

Technical requirements

The project setup in this chapter with the imported assets can be found on GitHub at https://github.com/PacktPublishing/Creating-an-RTS-game-in-Unity-2023 in the Chapter16 folder inside the project.

Exporting Dragoncraft for desktop

We have finished developing our Dragoncraft game with lots of cool features, and now we are ready to share it so other people can play the game you developed. The Unity Engine has a lot of platform options for exporting the game; however, some of them, such as gaming consoles, require licenses and extra setup. We are going to focus on the desktop platform, which is the most common and easy to use when sharing your game.

In this section, we are going to prepare our code and our project settings to export the game for desktop, and then how to manually build and run the game from the Unity Editor using the Build Settings window.

Preparing the Editor scripts

When we export our game from the Unity Engine to run on any platform, some pieces of code might not be available to run on the given platform, and that will cause an error when we try to build the game.

In our project, we used some APIs from Unity that are available only when we are running...

Creating a build system

We have learned how to export a build in the Editor using the Build Settings window. Now, we are going to see how to automate this process by creating a new BuildSystem script, which will use similar options to export the build through the UnityEditor API in the code instead of the Build Settings window.

Create a new script in the Scripts | Editor folder, name it BuildSystem, and replace the content with the following code block:

#if UNITY_EDITOR
using UnityEditor.Build.Reporting;
using UnityEditor;
using UnityEngine;
namespace Dragoncraft
{
  public static class BuildSystem
  {
    private static string[] _releaseScenes = new[] {
      "Assets/Scenes/Level01.unity",
      "Assets/Scenes/GameUI.unity"
    };
    private static string[] _debugScenes = new[] {
      ...

Expanding Dragoncraft

We have a complete RTS game with many features implemented. Now, it is time to see what we can do to expand it by adding more content, such as new enemies and units, a few variations, new upgrades, and new levels.

The first content we are going to see is how to add music and sound effects to the game, which is simple enough that after a couple of examples, you will be able to add as much as you want. After the music and sound effects, we will discuss how to add more content to the game, such as a main menu, new levels, units, enemies, and objectives, using the existing tools and features that we have developed in the book.

Adding music and sound effects

Music and sound effects are big parts of the game experience, helping players become immersed in the gameplay, but also providing audio feedback when completing certain actions or when certain events take place, for example. There are quite a lot of websites, such as Pixabay (https://pixabay.com/) and...

Summary

In this final chapter, we learned how to export our game as a build for the Windows and macOS platforms, and how to set up different build options and scenes for debug and release builds. We also learned how to automate the build process by creating a custom build script, as well as how to add new modules to the Unity installation. Finally, we learned how to add music and sound effects to the game, and a list of different content that can be added to the project using the tools and features we developed.

And with that, congratulations – you have reached the end of the book and created an RTS game from scratch! Take a moment to appreciate the game you have created and the new game development skills you learned through this book. Although the focus of this book was to create an RTS game, most of the content can be used to develop different game genres, and now you have the foundation to create many other projects. Congratulations one more time, and good luck with your...

Further reading

Here are a few links from the Unity documentation to learn more about the topics we have covered in this chapter as well as the Profiler, which we did not cover:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Creating an RTS Game in Unity 2023
Published in: Oct 2023Publisher: PacktISBN-13: 9781804613245
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime

Author (1)

author image
Bruno Cicanci

Bruno Cicanci is a software engineer and game developer with professional experience on different technologies and platforms. Since 2009, Bruno helped to develop and publish many games, mainly using Unity for mobile devices. He writes about game development on his personal blog, which led him to present many talks at universities and events. Bruno holds a Computer Science BS. Degree and a specialization and Game Production and Programming. In the last decade, he worked at prestigious game studios such as Glu Mobile, Electronic Arts, and Aquiris. He is currently developing games and reusable technologies at Ubisoft. Originally from Sao Paulo, Brazil, Bruno currently resides in London, UK with his wife and two adorable cats.
Read more about Bruno Cicanci