Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k
stars
435
forks
source link
Add a system to tag methods so they can only be executed either client-side or server-side #1878
In my code (and I would guess that is the case for many other users), I have, for a bunch of my mehtods executed only server-side, the following snippet of code:
if (!NetworkManager.Singleton.IsServer)
{
return;
}
I have the same, with IsClient, for my methods only executed client-side.
This system is heavy and error prone: I have to add this snippet manually every time and might forget to do it sometimes.
In my code (and I would guess that is the case for many other users), I have, for a bunch of my mehtods executed only server-side, the following snippet of code:
I have the same, with IsClient, for my methods only executed client-side. This system is heavy and error prone: I have to add this snippet manually every time and might forget to do it sometimes.
I believe Mirror has [Server] and [Client] decorators on methods, I'm guessing they're doing what I'm talking about. I think the relevant documentation page is https://mirror-networking.com/docs/api/Mirror.ClientAttribute.html .
I would love to see this feature added to Network for GameObjects, which would make our code both clearer and more stable.