Best Practices — 3 — Unity Overview

Samuel Asher Rivello
5 min readJun 14, 2024

--

Best practices in software and games!

Introduction

Hello and welcome to this series on best practices! In this article, we’re going to delve into best practices specifically within Unity. We’ll start with a brief introduction to Unity, discuss best practices, explore a case study, and finally, look at a demo. For more information on my thoughts on best practices in software and games, check out the other articles in this series linked above and in the description below.

My name is Sam, a game developer with over 20 years of experience and Unity certification. I’ve developed Unity games over the last decade and shipped titles for mobile, PC, Xbox, Steam, and more. I’ve also taught at universities and created online courses around game development best practices, programming, and the specifics of the Unity game engine. Now, let’s jump into an overview of Unity itself.

Overview of Unity

Unity is a versatile game engine that provides essential features like UI, input, audio, rendering, graphics, animation, and scripting with C#. Beyond these basics, Unity offers optional services like multiplayer gaming, analytics, ads, and monetization. Unity can be used across all stages of the software development life cycle but is most commonly utilized during the development phase. This phase involves coding, integrating art assets, and finally testing and deploying to your chosen platform.

Key Features of Unity
- UI and Input: Easy-to-use interfaces and flexible input options.
- Audio and Graphics: Advanced audio management and stunning graphical capabilities.
- Animation and Scripting: Smooth animation tools and powerful C# scripting.
- Optional Services: Multiplayer, analytics, ads, and monetization tools.

Essentials for Game Development

When developing with Unity, best practices are crucial. They encompass principles, standards, patterns, frameworks, and architectures that enhance the developer experience and project quality. Let’s explore some of these best practices in detail.

Unity Best Practices

Version Control and Unity Versions

Using version control, such as Git and GitHub, is essential for backing up your project, sharing it with others, and maintaining version history. It’s advisable to work with the latest Long-Term Support (LTS) version of Unity for stability and support. While exploring new features is exciting, for serious projects, sticking to LTS versions is recommended to minimize risks.

Best Practices

Efficient Settings and Structures

Optimizing your settings can significantly enhance your development workflow. For instance, using IL2CPP can improve game performance across platforms. Enabling “Enter Play Mode Options” can reduce compile times, though it requires specific code setups for stability.

Unity’s “Addressables” system is another powerful tool, replacing the older “Asset Bundles.” Addressables allow you to manage and optimize your game’s assets more effectively, improving both delivery and memory usage.

Design Principles and Patterns

Adopting solid design principles like DRY (Don’t Repeat Yourself) and KISS (Keep It Simple, Stupid) can streamline your development process. Standards such as organized project structures and consistent coding practices enhance maintainability and team collaboration. Design patterns provide solutions for common problems, and frameworks and architectures build on these to manage larger complexities.

When starting a project, it’s beneficial to consider these practices from the beginning. For instance, dividing your game into manageable scenes and using prefabs can simplify development and maintenance.

Advanced Practices and Automation

Scriptable Objects and Packages

Scriptable Objects offer an alternative to MonoBehaviour scripts for storing data, enhancing both editor-time and runtime efficiency. Additionally, incorporating packages like async/await libraries, localization, Unity’s input system, and UI toolkit from the start can provide significant advantages.

Automated Workflows

Automating your build process can save time and reduce errors. Set up automated builds that trigger upon code commits, and include automated unit tests to ensure code reliability. This approach ensures that you and your team can quickly identify and address issues.

For example, making any scene loadable directly from the editor and having a project that automatically builds itself can drastically improve development efficiency. Automated unit tests further enhance maintainability and scalability.

Coding Standards and Project Templates

Establishing and adhering to coding standards is crucial for team consistency and readability. A well-structured project template can also streamline development. Here’s an example of a recommended project folder structure:

Coding Standards & Project Structure

- ThirdParty: External libraries.
- Art: Sprites, images, animations, models.
- Documentation: Readme files, links, diagrams.
- Prefabs, Scenes, Resources: Unity-specific components.
- Scripts: Divided into Editor, Runtime, and Test folders.

By following these standards, you ensure a maintainable and scalable project, facilitating team collaboration and long-term project success.

Conclusion

In this article, we’ve covered a quick introduction to Unity, best practices in game development, and specific tips for Unity. For more in-depth information, check out the links and resources mentioned throughout this series. In the next article, we’ll dive into a Unity demo that showcases these best practices in action. Thanks for following along, and feel free to reach out for remote contract work within best practices or development projects.

Stay tuned for the next video in the series!

--

--

Samuel Asher Rivello

Game Developer & Instructor - Unity Certified. 20+ years of game dev XP. Available For Remote Hire. http://www.SamuelAsherRivello.com