Repository navigation
Value Hider
Tutorial in order to use the HidedValue script. Using the Value Hider can be useful to avoid memory value hacks though it will be not perfect.
When using a hided value, for example, for an int, you can do the following:
new HidedValue<int>( (v)=>{ return v + 1; }, (v)=>{ return v - 1; } );
This will save in memory the value of an int with an addition of 1. It will not be the safest formula but it is a cheap one and will make that memory hacks need to know the formula in order to use it.
Additionally, you can add an initial value:
new HidedValue<int>( (v)=>{ return v + 1; }, (v)=>{ return v - 1; }, 0 );
If not, it will take the default of T.
In order to use it, the only thing you will need to do is to use the hided value Value var inside. For example:
Debug.Log(hidedValueVar.Value);
The get and set it has will do the rest. This will also work when setting values.
- HidedValue(Func<T, T> hideMethod, Func<T, T> showMethod) - Creates a hided value
- HidedValue(Func<T, T> hideMethod, Func<T, T> showMethod, T initialValue) - Creates a hided value with an initial value
- T Value - Get and set that hides or shows depending on need