In Unity, when we talk about ‘fields,’ we’re essentially referring to the adjustable settings or properties within a script that help define how different game elements behave. These fields act like containers for various types of information, such as numbers, text, references to other objects, and more.
Let’s say you’re creating a script to control a player’s behavior. Within that script, you can set up fields to control different aspects. For instance, you might have a field called ‘health,’ which tracks the player’s health points, or a ‘speed’ field that determines how fast the player moves. These fields can be easily adjusted right within Unity’s Editor without needing to change the underlying code.
Here’s a quick example:
using UnityEngine; public class PlayerController : MonoBehaviour { public int health = 100; public float speed = 5.0f; public string playerName = "Player One"; public GameObject targetObject; }
Once you attach this script to a player GameObject, Unity’s Inspector window will show these fields, allowing you to modify them directly. You could change the health value, adjust the speed, or even assign another GameObject as the targetObject—all without touching the code.
Now in today’s tutorial I will show you how you can easily modify these fields to your advantage by hooking them to a method.
Requirements:
1) Knowledge of how to use the Tools Injector Mod Menu
2) Basic knowledge about modding games.
For this tutorial we will be using a game called Werewolf Romance – Story Game, you can download it by clicking here. In this game there are hints which you can use while making choices, the hints cost gems, and it helps you make better choices.
We will modify the cost of the hint, which is a field, to a negative number so that we gain gems every time we use a HINT.
This is not a beginner’s tutorial, make sure you have some basic knowledge about how to mod unity games.
Let’s begin!
1) Dump the game and load the DummyDLL files in DNSPY
2) Change the search for to All of the Above
3) Now search for the keyword COST
The cost field inside the AffectionHandler class looks interesting, and we can MOD that, that holds the price value of the gems for the buying hints.
You will find many other fields with the same name, but you just have to find the right one by modding each of them, some may work and some may not work, so you just need to try.
4) Launch the Tools Injector Mod Menu
Right-click on the white space and click Add
Choose Function Type as Hook Button On/Off & Toggle
Right Click again on the white space and click ADD
Now Pay Attention Here
In the offset section we need to attach this field to a method that constantly updates or is called in the game, so in this class find a method such as: start, update, init, awake
In the AffectionHandler we have both Awake and Update method, so just hook the cost field to Update method.
- Name = Add name of the methods, or fields to help you remember next time you want to update the game
- Offset = This is the offset of the Update method we spoke about above
- Type = Update Method type is VOID so choose VOID, Fields should always be hooked to Voids
- Field Type = The cost Field is an INT, so choose INT
- Field Offset = Paste the Field Offset
- Value = Enter the value you want, in my case -800 so that the cost of the hint will be negative 800
5) Now click Add Function and Compile the APK file and send it to your device for testing.
Now, when I purchased the HINT, I got 800 gems in the game.
Please note that if the cost field does not work, try also hooking it to a different method, like update, or init.
I hope you learned something new today. If you have questions, then comment below, and I will try to answer them.