UnityNetworkMessages
API that allows sending messages inside Unity games that use Netcode for GameObjects without having to create Prefabs with NetworkObjects.
模組介紹 作者原文
Unity Network Messages
C# Library that allows sending messages and events inside Unity games that use NetCode for GameObjects without having
to create prefabs with NetworkObject components.
Library created mostly for personal usage, I'll add a wiki and some examples at some point.
Network Variables might come at some point too.
For now mostly tested on LAN.
Features
- Global events and messages
- NetworkObject events and messages
- Vanilla-friendly!
F.A.Q.
How is it "Vanilla-friendly"?
Most Network APIs i've found use NetworkObject prefabs to run code, which for games that force said prefabs compatibility
(e.g. Lethal Company) means that any client who's trying to join a server that doesn't have the same network prefab
list will get rejected.
In this mod's case, you are free to join a non-modded server!
Obviously, any logic that would require the server's intervention will not work, but the server will be joinable.
Available classes:
Global event/messages
These classes have a global identifier, meaning that all messages registered with the same identifier across your mod
will receive the event/data when called.
- `GlobalNetEvent`
- Simple event without data.
- `GlobalNetMessage`
- Message that can transmit data, tested working with unmanaged primitives, structs and strings.
Object event/messages
These classes are registered with a NetworkObject, meaning that 2 events with the same identifier but a different NetworkObject
will not communicate between each other.
It also means that the events are only valid during the lifespan of the NetworkObject.
- `ObjectNetEvent`
- Simple event without data.
- `ObjectNetMessage`
- Message that can transmit data, tested working with unmanaged primitives, structs and strings.
Acknowledgements
I got the idea of using OdinSerializer from Xilophor's LethalNetworkAPI!
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: