Reading private variables
Reading private variables is clearly necessary when modding raft. Let's see how easy it is!
To access private variables we need to use Harmony. You can visit the Harmony wiki by clicking here.
Harmony is a library for patching, replacing and decorating .NET and Mono methods during runtime.
To use harmony you simply need to add the Harmony
namespace by adding using Harmony;
at the top of your class.
To access a non-static private variable you use Traverse.Create() with the object instance and .Field() with the field name.
To access a static private variable you also use Traverse.Create() but with the class type and .Field() with the field name.
Last updated