Skip to content

Commit 911d490

Browse files
authored
Update README.md
1 parent de740f9 commit 911d490

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Unity Netcode Patcher
23
**This is an assembly patcher which replicates the IL Post Processing that unity does with it's Netcode For Gameobjects Package, allowing you to create custom NetworkBehaviours in mods as if you were doing it in a Unity project.**
34

@@ -7,5 +8,52 @@
78

89
*Note, this is intended to be a tool for modders, mods should be shipped after patching and this tool should not be installed by users.*
910

10-
## Usage
11-
**Will be updated in a little while.**
11+
## Installation
12+
13+
1. Download the latest release from [Releases](https://github.com/EvaisaDev/UnityNetcodeWeaver/releases)
14+
2. Move NetcodePatcher folder from the zip into any location, I will have it in `O:/NetcodePatcher` for this tutorial.
15+
3. Move contents of `GameFolder/GameName_Data/Managed` into `NetcodePatcher/deps`
16+
4. Add the following snippet to your mod, in a place where it will only run once, such as `Awake()`
17+
- **It is very important that it only runs once!**
18+
```cs
19+
var types = Assembly.GetExecutingAssembly().GetTypes();
20+
foreach (var type in types)
21+
{
22+
var methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
23+
foreach (var method in methods)
24+
{
25+
var attributes = method.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), false);
26+
if (attributes.Length > 0)
27+
{
28+
method.Invoke(null, null);
29+
}
30+
}
31+
}
32+
```
33+
34+
## Usage from command line
35+
36+
1. Take your compiled plugin, including any dependencies, and move it into `NetcodePatcher/plugins`.
37+
- You have to also include the plugin PDB file, the patcher requires this in order to work.
38+
- Plugins can be in sub directories, for example `NetcodePatcher/plugins/LethalThings/LethalThings.dll`
39+
2. Open command line in plugin location, and run `NetcodePatcher.dll plugins/ deps/`
40+
3. If everything went right, you should see `Patched (AssemblyName) successfully`
41+
- The patched assembly will replace the original in the NetcodePatcher plugins folder.
42+
43+
## Usage as a Post Build Event in VS
44+
45+
Example post build event:
46+
```
47+
xcopy "$(TargetPath)" "O:\NetcodePatcher\plugins\LethalThings" /Y
48+
xcopy "$(TargetDir)$(AssemblyName).pdb" "O:\NetcodePatcher\plugins\LethalThings" /Y
49+
cd O:\NetcodePatcher
50+
NetcodePatcher.dll plugins/ deps/
51+
xcopy "O:\NetcodePatcher\plugins\LethalThings\$(AssemblyName).dll" "C:\Program Files (x86)\Steam\steamapps\common\Lethal Company\BepInEx\plugins\LethalThings" /Y
52+
```
53+
Essentially what it is doing is copying the assembly and the pdb file from the output folder, and running the patcher.
54+
Then copying the patched assembly to the plugins folder.
55+
56+
## Credits
57+
58+
- **nickklmao**
59+
- for helping me test and find issues with the patcher.

0 commit comments

Comments
 (0)