You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 9, 2025. It is now read-only.
Daniel Everland edited this page Nov 8, 2018
·
3 revisions
Introduction
Clamped Variables were created for two very simple reasons. We very often would like certain values to stay within a specific interval, and the point of ScriptableObject-Architecture being that we want to avoid constrictions of codebases. Let's imagine having a PlayerHealth variable without the Clamped Variable feature
We obviously don't want the PlayerHealth to exceed the maximum allowed health, nor do we want it to dip below 0. We would have to ensure that every single piece of code that references this variable ensured to clamp it properly, or force them to assign it through a static function that did it for them. That's not very Unity-like. So instead I decided to make a variable that does this dynamically. Code that references such an object doesn't need to know which values to clamp it to, it can simply assign whatever value it pleases without worry.
Script Reference
Clamped Variables inherit IClampedVariable<TType, TVariable, TReference> which contains the following members