Unity-Technologies / Unity-Technologies/com.unity.netcode.gameobjects

ClientRpc and ServerRpc decorators should give an error if attached to a non-NetworkBehaviour class method

Aperta
#1,911 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Tracking type:feature
Lingua principale
C#
Stelle
2.3k
Fork
461
Merge medio
3g 16h
PR unite (30g)
20

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

La issue non indica file, test o punti di ingresso. Inizia individuando la gestione dei decorator ClientRpc e ServerRpc e il modo in cui viene verificata l’ereditarietà da NetworkBehaviour; definisci e testa una diagnostica per i metodi nelle classi che non derivano da NetworkBehaviour, incluso il comportamento richiesto a runtime o nell’editor.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
networking
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.