[Beta 2] UNet weaver error for virtual methods

In our project all UNet commands and RPCs (about 40 methods) are defined as empty virtual methods on base class NetworkPlayer and have implementation in derived classes: one for server project and two for client project (1st person and 3rd person players).

Now when opening the project in 2017.1.0b2 I get the following error which weren’t there in the first beta:

Is this a breaking change or is this a bug?

1 Like

So overridden virtual functions have never worked with Commands and RPC functions, this error message was explicitly added for now to inform users to avoid overriding these type of functions.

@MichalBUnity I don’t think that’s true. In our project they worked perfectly fine at least since 5.3 up to 5.6 and 2017.1.0b1.

1 Like

How do you guys invoke the command calls?

Might be that i have missed a use-case and if that is the case i would very much like to see how you guys implement and invoke your Commands.

public class Player : NetworkBehaviour
{
    ...
}

public abstract class NetworkPlayer : Player
{
    ...
    [Command] protected virtual void CmdSearchContent(string itemId, uint callbackId) { }
    [ClientRpc] protected virtual void RpcSetDamageCoeff(float damageCoefficient) { }
    ...
}


public class ServerPlayer : NetworkPlayer
{
    protected override void CmdSearchContent(string itemId, uint callbackId)
    {
        // server logic here
    }
}

public class ClientPlayer : Player
{
    protected override void RpcSetDamageCoeff(float damageCoefficient)
    {
        // 1st-person logic here
    }
}

public class ObservedPlayer : Player
{
    protected override void RpcSetDamageCoeff(float damageCoefficient)
    {
        // 3rd-person logic here
    }
}

Then we invoke them as usual:

    // on client
    ...
    Player.CmdSearchContent(operation.Item.Id, confirmId);
    ...

    // on server
    ...
    RpcSetDamageCoeff(damageCoefficient);
    ...
1 Like

Thanks for the information, and you are correct this would work for you guys. I will revert this change and instead update the documentation regarding Commands, RPCs and virtual functions to avoid issues while we work to make it safe for every inheritance use-case.

I would recommend you to go back to 5.6 or 2017.1.0b1 for now, I’m sorry for the inconvenience this have caused. I’ll get back to you when i know when the fix will be out.

No worries, I’ve got a separate branch for testing out beta versions. Just trying to detect and report any issues as soon as possible, before they seep into main release.

1 Like

This seems to be fixed in the latest beta (b4). The project compiles fine now.

2 Likes