Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 8e03d03

Browse files
Updated documentation
1 parent 2ce5b3a commit 8e03d03

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Introduction
2+
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
3+
4+
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.
5+
6+
## Script Reference
7+
Since we're clamping an unknown type, it is impossible for me to make an implementation that'll definitely work with everything. I could write a relatively safe implementation of Mathf.Clamp, but if you're using any known numerical value, I've already implemented a Clamped Variable type for you, so it seemed like a bad idea to make such an assumption.
8+
9+
abstract TType ClampValue(TType value);
10+
11+
TReference MinValue { get; }
12+
TReference MaxValue { get; }

Assets/SO Architecture/Documentation/Clamped-Variables.txt.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

Assets/SO Architecture/Documentation/Collection.md.meta renamed to Assets/SO Architecture/Documentation/Collection.txt.meta

File renamed without changes.

0 commit comments

Comments
 (0)