Skip to main content

Unity Atoms Framework

Unity Atoms is a core tool within our development pipeline at Gnarly Game Studio, significantly streamlining various aspects of game development. Unity Atoms is a modular, event-driven framework built on top of Unity's ScriptableObject architecture. Its primary goal is to promote data separation and reduce direct dependencies between objects, which is crucial for creating flexible, scalable, and maintainable systems. By leveraging this framework, we ensure that our games are more modular, easier to debug, and responsive to state changes, all while maintaining clean and efficient code.

Key Benefits of Unity Atoms

1. Data Separation

At the heart of Unity Atoms is its ability to maintain a clear separation between data and behavior. By utilizing ScriptableObjects, we can store data independently of MonoBehaviours and scenes. This is crucial for creating a robust and flexible data management system, where values persist across sessions, scenes, and even builds.

For instance, we use Unity Atoms to manage nearly all data in our games, including:

  • Character Health Values: Player and enemy health stats are stored in ScriptableObjects, allowing health data to persist across different scenes or even between play sessions.
  • Damage Points: When a character or enemy deals damage, we reference Atom-based values that define how much damage they inflict, ensuring easy tuning and balance.
  • Skill Cooldowns and Durations: Timers for skill cooldowns, buff durations, or effects are managed via ScriptableObjects, ensuring the values are flexible, easy to debug, and modifiable without creating hard dependencies.
  • Player Experience and Leveling: Experience points required to level up, or even the entire leveling system, can be controlled using Atom variables, making it easy to tweak and evolve game balance.
  • Resource Collection: Values for collecting in-game resources (like currency, health pickups, or crafting materials) can be stored and updated in Atoms.

This separation ensures that all of our data remains flexible and easily modifiable, without the risk of breaking other systems. We can adjust values like health, damage, or cooldown durations without rewriting game logic, simplifying tuning and balancing phases.

2. Easy-to-Use Debugging Features

One of the significant challenges in game development is identifying and fixing issues that may arise in the complex interactions between game objects, systems, and mechanics. Unity Atoms shines in this area by offering easy-to-use debugging tools. Because ScriptableObjects are asset-based and live outside of MonoBehaviours, they are accessible in the Unity Editor even while the game is running. This allows us to:

  • Inspect Variables in Real Time: View and adjust Atom-based variables directly within the Unity Editor as the game runs. For instance, if a character’s health or an ability’s cooldown is behaving unexpectedly, we can adjust these values on the fly.
  • Trigger Events and Test Reactions: By using custom Atom events, we can fire off events directly from the Unity Editor to test how various systems react. For example, we can simulate a damage event or force a level-up event without needing to trigger these events in-game manually.
  • Simplify Data Debugging: Since data is stored separately from MonoBehaviours, pinpointing specific variables and their state at runtime is far simpler. Instead of sifting through complex object hierarchies, we can modify ScriptableObjects directly, reducing the time spent on debugging and improving overall development efficiency.

3. Reactive Programming Paradigm

At its core, Unity Atoms embraces the reactive programming paradigm, which emphasizes the flow of data and the automatic propagation of changes. In game development, this means that when data changes, the systems relying on that data automatically react, reducing the need for constant manual updates or checks.

With Unity Atoms, events and actions automatically respond to changes in a game’s state. For example:

  • UI Updates: When a player’s health changes, the health bar UI can be automatically updated through Atom variables, eliminating the need for manual updates or polling.
  • Player Stat Changes: Imagine a system where power-ups increase a player's speed or strength. By using Atom variables, any gameplay elements (like character movement or animation) that depend on these values will instantly respond when the power-up is applied or expires.

The reactive nature of Unity Atoms ensures that our game systems remain synchronized without requiring the use of complex, hard-to-maintain code to keep everything in sync. This reduces potential bugs, simplifies logic, and makes the codebase more manageable.

4. Custom Data Class Support with Unity Atoms Generator

One of the most powerful features of Unity Atoms is the Generator tool, which allows us to automatically create Atom variables, events, and other assets for custom data classes. At Gnarly Game Studio, we rely heavily on this feature to manage custom data types, which are used extensively throughout our games.

Learning and Mastering Unity Atoms

For those new to Unity Atoms, we highly recommend diving into its official documentation, which covers everything from installation to specific features like events, variables, collections, and more. Additionally, ScriptableObjects play a vital role in the functionality of Unity Atoms and Unity itself. You can learn more about their versatility and persistent data storage by reading the Unity Manual.

For a deeper understanding of how ScriptableObjects can be used in game architecture, we also recommend checking out the Unite Austin 2017 talk, which offers an in-depth discussion on structuring games using ScriptableObjects.