Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects
ClientRpc and ServerRpc decorators should give an error if attached to a non-NetworkBehaviour class method
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.3k
- 分支
- 461
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 20
描述
Is your feature request related to a problem? Please describe.
I'm finding it easy to accidentally add [ClientRpc] or [ServerRpc] methods to MonoBehaviour-derived classes, where clearly they won't do anything. This leads to a bunch of confusion while I try to figure out what's wrong with the networking only to do the forehead-slap when I notice that the class hasn't been switched to NetworkBehaviour.
Describe the solution you'd like
At a minimum, a runtime error with a descriptive error message would be helpful. Something like "FooClientRpc was added to a class that doesn't derive from NetworkBehaviour - as a result, FooClientRpc will never be called."
Better would be a similar error logged when in the editor. Compile-time errors would be ideal if possible, of course.
Describe alternatives you've considered
Beyond "vigilance" (which can be assumed doesn't work), if it becomes a more serious issue then I'd have to rig some sort of linting rule to catch this.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
該 issue 沒有指出檔案、測試或進入點。首先定位 ClientRpc 和 ServerRpc 裝飾器的處理方式,以及如何檢查 NetworkBehaviour 繼承關係;為不繼承自 NetworkBehaviour 的類別中的方法定義並測試一項診斷,同時包含所要求的執行階段或編輯器行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp
- 領域
- networking
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 35/100