I’m the author of an open source library for the game engine Unity called Unity Atoms. The library is inspired by this talk by Ryan Hipple from Unite 2017. I started working on the project in October 2018 and back then it was meant for internal use in my current game side project. Since then it has, after many late nights of work, grown and become a full fleshed solution for working with Scriptable Objects within Unity. Today I’m proud to finally announce that version 2 of Unity Atoms is released 🎉

❓ So what is it and how do I use it?

At its core, Unity Atoms makes Variables, Events, Listeners, Actions and Functions into modular reusable pieces of code by leveraging the power of Scriptable Objects. Together with Unity’s inspector this makes your code much more modular and testable. Below follows a simple example on how this looks in practice.

First create a MonoBehaviour with an IntVariable called Health describing the health of our game’s player:

The IntVariable is a Scriptable Object ( .asset file) that could be injected via Unity’s inspector:

The IntVariable will look like this when inspecting it:

We can now use and reference the Player’s health in other scripts by just injecting the IntVariable via the Inspector:

No more direct dependencies between your MonoBehaviours, eg. doing this in your health bar script: player.GetComponent<PlayerHealth>().Health -= 10f; . Hurray! 🥳

For a more detailed description of how to use the library, read my Unity Atoms announcement blog post. When you are done reading the blog post you can head over to the brand new website for more tips and tricks.

🚀 New features

The goal of Unity Atoms version 2 has been to improve the overall developer experience and to polish the APIs making it easier to work with. Here are some of the highlights included in version 2:

Mono repo: The project has been made into a mono repo and the code has been split up into 6 different packages: core, mono-hooks, tags, mobile, scene-mgmt and ui. You can now pick and choose exactly what you need for your project.

The project has been made into a mono repo and the code has been split up into 6 different packages: core, mono-hooks, tags, mobile, scene-mgmt and ui. You can now pick and choose exactly what you need for your project. Code generator: Unity Atoms version 2 includes a powerful code generator that can be accessed from the top menu bar: Tools/Unity Atoms/Generator . This makes it a breeze to create your own Atoms specific to your project.

Unity Atoms version 2 includes a powerful code generator that can be accessed from the top menu bar: . This makes it a breeze to create your own Atoms specific to your project. UniRx support: Events ( OnEvent ), Variable Events ( Changed and ChangedWithHistory ) and List Events ( Cleared , Added and Removed ) can now be turned into IObservables<T> making Unity Atoms work great with UniRx.

Events ( ), Variable Events ( and ) and List Events ( , and ) can now be turned into IObservables<T> making Unity Atoms work great with UniRx. Custom PropertyDrawers: All Atoms now have custom PropertyDrawers.

All Atoms now have custom PropertyDrawers. Custom editor icons: All Atoms now have custom editor icons.

All Atoms now have custom editor icons. New website: As part of making Unity Atoms more available to developers we have launched a new website full of examples and documentation.

🔮 What’s next?

Version 2 is a great step forward for the library, but we want to take things even further. Here follows a list of things that we are currently looking into:

Polishing up the Editors and PropertyDrawers even more.

Investigate how Unity Atoms could integrate with DOTS.

Variable post processors, eg. clamp value (int, float, etc.).

Improve debugging.

More generator options, eg. generation of multi value Atoms.

We also want to listen to the community and implement features that you find valuable. If you got an enhancement that you want to add to Unity Atoms then head over to the issues pages on Github.

We are also looking for more contributors and maintainers for Unity Atoms. Please contact us if you to help the project by becoming one.

Thanks for reading! If you liked what you just read and want to see more of this in the future, then give the post some 👏 and follow me on twitter.