Installation and configuration
In this chapter we will look at how to install and configure UnityInjector.
Note: UnityInjector is installed using ReiPatcher (or Sybaris). Make sure you have it downloaded and configured before proceeding any further.
Copying files
After you have downloaded UnityInjector, unpack the archive. In it there should be at least the following files: ExIni.dll
, UnityInjector.dll
and UnityInjector.Patcher.dll
. Depending on the game and your particular configuration of ReiPatcher for the game, do the following:
- Place
ExIni.dll
andUnityInjector.dll
into<Game Root>\<Game Code>_Data\Managed
folder, where<Game Root>
is the folder where the game’s executable resides and<Game Code>
is the name of the game’s executable. - Place
UnityInjector.Patcher.dll
into<ReiPatcher Root>\<Patchers>
folder, where<ReiPatcher Root>
is the folder whereReiPatcher.exe
resides, and<Patchers>
is the folder that contains the patchers for the target game. Usually the<Patchers>
folder is just calledPatches
, but you can check the exact folder name in ReiPatcher’s game configuration INI file by looking at thePatchesDir
key. If you don’t have a game configuration, you can get or create one as described in the ReiPatcher guide. - In the
<Game Root>
folder, create a folder calledUnityInjector
Configuring UnityInjector
UnityInjector relies on ReiPatcher and uses the game configuration file to patch an appropriate method.
Note: If you have downloaded pre-made game configurations, the configuration file will most likely have the needed properties specified. In that case you can read how to install plugins.
In case there are no pre-made configurations, or UnityInjector’s patcher fails to inject methods, you will have to edit the game configuration yourself. To do that, do the following:
- Head to the folder where ReiPatcher is installed.
- Locate the INI configuration file for the game. If there is no such, download or create one yourself.
- Open the configuration file in your favourite text editor.
- At the end of the file, add the following:
1
2
3
4
[UnityInjector]
Assembly=
Class=
Method=
UnityInjector’s patcher will use these properties to inject some initialisation code into some assembly of the game. Here is a table that describes each property in more detail.
Property | Description |
---|---|
Assembly |
The name of the assembly to inject initialisation code into. The assembly is written without the file extension, i.e. MyAssembly instead of MyAssembly.dll . |
Class |
The class in the specified Assembly to inject initialisation code into. The name must contain the namespace of the class (unless the class does not belong to any namespaces), i.e. MyNamespace.SomeClass . |
Method |
The method in the specified Class to inject initialisation code into. |
To fill in the values, you will have to use a .NET decompiler (such as ILSpy, Cecil Studio, dotPeek and .NET Reflector) to search through game’s assemblies and locate a suitable class and method to inject UnityInjector initialisation code into.
Here are some tips on finding a proper method to inject:
- You can use any game assembly located in
<Game Root>\<Game Code>_Data\Managed
folder, where<Game Root>
is the folder where the game’s executable resides and<Game Code>
is the name of the game’s executable. Moreover, you can use any class and any method found in the assembly, as long as the method is run once when the game loads. - Most commonly used assemblies are
Assembly-CSharp
andAssembly-UnityScript
. - Most commonly used classes inherit
MonoBehaviour
and contain such words as “start” and “scene”. - If the chosen class inherits
MonoBehaviour
, you can useAwake
orStart
as the value ofMethod
(as long a method with such name exists). - You can inject the code into constructors by using
.ctor
as the value ofMethod
, but it is not preferable. - Make sure the chosen method is called only one time. In addition, attempt to chose a method that is called right after the game loads.
- If you are unsure of which method to choose, do it in a trial-and-error fashion: specify some values for the above-mentioned properties, run ReiPatcher and load the game to make sure the patch was successful. If everything went to plan, you will see a console window appear when the game loads. If nothing happens, simply restore the patched assembly and choose a different method.
Patching the assembly
Once you have the game configuration edited and saved, just run ReiPatcher (as described in ReiPatcher’s guide).
If no errors occurred, run the game executable. If you see a console window appear alongside the game, that means you have successfully installed UnityInjector! You can now install and run plugins.
Installing a plugin
A plugin is a separate DLL file that is put to the UnityInjector
folder located in the game’s root folder. To install a plugin, do the following:
- Download the plugin.
- Place the plugin DLL (usually the one ending with
Plugin.dll
) into<Game Root>\UnityInjector
folder, where<Game Root>
is the folder where the game’s executable resides. - Place any additional files in the folder specified in the plugin’s installation instructions.
- Run the game. If the plugin was installed successfully, you will see a “Plugin loaded” message in the debugger console.