Hello, everyone!
I wanted to share a minimal architectural solution I’ve been using for several years hoping it will also help someone else.
I prefer writing classes that don’t inherit from MonoBehaviour or ScriptableObject (aka, POCOS) because they limit usability and couple me to Unity. Additionally, some classes can’t inherit from MB and SO for various reasons we’ve all encountered. So, what’s the workaround? You let a MonoBehaviour or ScriptableObject encapsulate them.
This is where my concept of Scriptable Holders comes in. It’s essentially a Scriptable Object that wraps around a regular serialized class. My initial use case was to conveniently debug API calls in the editor and make changes to them at runtime. While I couldn’t inherit from SO for API responses, wrapping the regular class in a ScriptableObject gave me the best of both worlds.
This approach is quite similar (semantically) to Lazy, acting as a simple decorator that adds capabilities to a class.
Recently, I enhanced the user experience of this solution in Unity and wrote a brief article about my editor scripts and the value of Scriptable Holders.
I’d love to hear your thoughts! Would you use a class like this? Have you done something similar?
Read the article here
Editor-wise, I discuss eliminating the default foldout arrow in Unity and changing class icons at the code level.
Check out the GitHub examples