Purpose

Scriptable Singleton

Soap is a framework that helps eliminate regular Singletons to decouple your code. So you might be wondering: why is there a Scriptable Singleton in this package? I hesitated for a long time before including it in the core package, but here’s why I eventually did:

During fast iteration cycles (game productions of one to two weeks), I kept needing a single place where I could tweak all the different parameters of my game. I didn’t want to dig through each prefab to change the speed of something or the number of coins spawned in a level. On top of that, I’m lazy—I didn’t want to create a ScriptableObject that I then had to reference manually everywhere I needed a global value. I also didn’t want to create individual variables for each value. And I definitely didn’t want to use a regular Singleton, since it would be scene-bound and would reset its values every time I exited Play mode.

Example in one of my game:

Another reason was related to making creatives (videos) for campaigns. You often have to record A LOT of footage. To quickly produce different videos, I added a bunch of convenient options like “feature X enabled” which would hack the gameplay but were easy to toggle on/off for recording. This was incredibly useful for quick iteration—and sometimes, when a “hacky” feature turned out fun, I would even enable it for certain cohorts to test if it improved retention.

Example of how I used it as a game params + feature enable in another game:

In the end, what I wanted was simple: I wanted to be able to call GameParams.Instance from anywhere and keep the values in a ScriptableObject that stays docked in the Inspector as a window. That setup let me tweak values in the editor or at runtime whenever I wanted, from anywhere in the project. Once I was happy with certain values, I’d usually remove them—but for some options, I kept them around. I also used this SO to store other things, like references to ScriptableObjects I wanted to debug quickly. Basically, it turned into a “put anything you always want at your fingertips” basket.

Last updated