(SOLVED)Any performance issues on HLAPI attributes?

Good afternoon.
Devs, Is there any performance problems with functions marked as [Client], [Server], [ClientCallback] etc?
As I know it’s reflection stuff which is slow, or not?

Thanks.

SOLVED: Seems like attributes just tell compiler to add condition so it will be added to your standalone build.

That’s how code looks after decompilation.

if(!NetworkClient.active) for client callback

And if(!NetworkServer.active) for server callback.

Yes, mostly those attributes used for the UnetWeaver to properly add some logic during code generation. So there’s low impact on the performance during runtime. Though, checks are still checks. Don’t use them where they’re not needed.

1 Like

a bit off-topic, is there any ways to override NetworkWriter writing method, I want to implement protobuf serialization of messages.

I don’t think so, they aren’t marked as virtual. You can always try implementing your own though. Take a look at src, you may find something usefull there:
https://bitbucket.org/Unity-Technologies/networking/src/00db70190c0e83f9567790fd0fc60e30f4fe1c96/Runtime/NetworkWriter.cs?at=5.6&fileviewer=file-view-default

1 Like