One of the oldest and easies way to cheat in games is to use tools that modify values directly in device memory. There are many free programs like Cheat Engine and also programs for mobile devices to do this. It doesn't require any particular hacking skills either.

Problem is that whenever program is saving primitive data like integers to memory, they are saved in plain format. In games for example score, lives etc. With right tools this memory address can be found and inject any wanted value there. And player have infinite amount of anything he wants.

HiddenVars is simple package to hide values like integers, floats, booleans, strings and others. Technically, whenever any value is saved, it is first converted to byte array which is then "xor'd" using pseudorandom bytes and then saved to memory. Every time value changes, resulting bytes are seemingly totally different and also saved to new location in memory. This makes tracking down location of important data extremely difficult.

HiddenVars is meant to hide values during runtime only. There's no methods to save values to any permanent storage.

How to use

Simply create new HiddenVars instance in your code using

HiddenVars hiddenVars = new HiddenVars();

You can then save and read different type of data using Set and Get methods.


Since integers are most common data to be saved securely, you can also use indexer to save and read integers:

HiddenVars hiddenVars = new HiddenVars();
hiddenVars["score"] = 0;
hiddenVars["score"] += 100;
Debug.Log("Current score: "+hiddenVars["score"]);

Default values

All Get methods have also second version where you can define default value in case value is not available. This is handy when it is completely okay that some value doesn't yet exist. For example:

int lastGameScore = myHiddenVars.GetInt("LastGameScore",0);
string previousMessage = somehiddenvars.GetString("previous_message",null);

Note: No type check

There is no type check when reading values. If you save some value as int and try to read it out as long, you end up getting error message. Or if you save something as string and then try to read it as int, results may vary. You may get error message or you may get back some meaningless integer value.

So make sure to read values using same type that is used to save them.

Debugging in Unity Editor

When running your application in Unity Editor, first call to HiddenVars will create gameobject "HiddenVars EditorOnly RunTimeDebug" to hierarchy.

When choosing this object, you can see current content of all HiddenVars instances in the Unity inspector window.

This gameobject will not appear in builds outside Unity Editor and it can be also deleted during runtime without any effect to actual functionality of HiddenVars.

Full API docs

Full API documentation

Where to get

Download free from Unity Asset Store