Skip to content

Value Hider

Facundo Balboa edited this page Apr 17, 2019 · 2 revisions

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.


Create a HidedValue

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.

Use a HidedValue

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.

Constructors

  • 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

Public Vars

  • T Value - Get and set that hides or shows depending on need

Clone this wiki locally