- Home /
Cannot use Delegate in Unity Multiplayer (C#)
I am using Delegate for callbacks in my game.
When it comes to Multiplayer, it throws a compile error
UNetWeaver error: The class MyDelegate has no default constructor or it's private, aborting.
My Delegate is Public in class Abc .
public class Abc: NetworkBehaviour
{
...
public delegate void MyDelegate();
...
}
Is that all the code? How did UNetWeaver
get involved? In this code fragment, $$anonymous$$yDelegate
is definitely not a class.
The problem is not the delegate definition but where and how you used it. You clearly used it either as type of a "SyncVar" or in conjunction with a "Command" or "ClientRPC" attribute. Those three attributes are used to perform post-compilation-modifications to your code. Those modifications are done by the UNetWeaver. Delegate types can't be syncronised across the network.
At the end of this page is a list of types that can be serialized across the network.
Thank you .. As you said the problem is , I used $$anonymous$$yDelegate with a Command method. The purpose was excecuting an anonimous functions after excecuting the Command method. for that I used $$anonymous$$yDelegate parameter .
Your answer
![](https://koobas.hobune.stream/wayback/20220612123847im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Master Server GUI not showing up [Errors finally coming up in console] 1 Answer
Store Data Online 0 Answers
delegate as animation event 1 Answer