Skip to content

Commit aa7356d

Browse files
authored
Update README.md
1 parent 90ebec5 commit aa7356d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Make sure Debug Symbols are set to `Portable` or `Embedded` and not `Full`.
1717
- To ensure that the patched NetworkBehaviours are initialized properly, add the following code snippet to your mod, in a place where it will only run once, such as `Awake()`
1818
- **It is very important that it only runs once!**
19+
- If you have soft dependencies of some kind, you might need to wrap this in a try catch block.
1920
```cs
2021
var types = Assembly.GetExecutingAssembly().GetTypes();
2122
foreach (var type in types)
@@ -31,6 +32,10 @@
3132
}
3233
}
3334
```
35+
36+
- The reason we need to do this is because NetcodePatcher generates methods marked with `[RuntimeInitializeOnLoadMethod]` for initializing the RPCs, which normally get ran when the class gets loaded.
37+
However because the mod assembly is not managed by unity, these methods will not be ran automatically.
38+
So using this snippet we manually run every method marked with `[RuntimeInitializeOnLoadMethodAttribute]`.
3439
- Make you register any custom NetworkObject prefabs with the unity NetworkManager.
3540
- networkManager.GetComponent<NetworkManager>().AddNetworkPrefab(prefab);
3641

0 commit comments

Comments
 (0)