UNET Rpc calls wrong inherited script

Hi All,

So here’s the setup:
I have a GameObject with a Network Identity and Local Player Authority.
I have a base class and two child classes that extend the base class. The base class makes an Rpc call.

I want to put both of these child classes on the same object, but when I do that, the Rpc call executes on the first class attached to the object, rather than the one that made the call.

Of course, I could have a child object with a separate NetworkIdentity store one of the Child classes, but I wanted to know whether this is a bug in Unity, or if it’s intended behavior, or if I’m just doing something wrong.

The “Base” class looks something like this:

using UnityEngine;
using UnityEngine.Networking;

public abstract class Base : NetworkBehaviour {

    // The client's player object
    public GameObject player;

    public void Execute() {
        if(player.GetComponent<NetworkIdentity>().isServer)
        {
            RpcExecute();
        } else {
            CmdExecute();
        }
    }

    [Command]
    public void CmdExecute() {
        RpcExecute();
    }

    [ClientRpc]
    public void RpcExecute() {
        Actions();
    }

    public abstract void Actions();
}

And the two sub-classes, ChildA and ChildB, both look like this:

using UnityEngine;
using UnityEngine.Networking;

public class ChildX : Base {
    public override void Actions {
        // Execute some actions here
    }
}

Any feedback is appreciated!

public int rpcId;//Specific id
private int mRpcExecuteHash ;
private string mRpcExecuteName ;
private NetworkWriter mRpcExecuteWriter = new NetworkWriter();

public override void OnStartClient()
     {
            base.OnStartClient();
            mRpcExecuteName = "RpcExecute:" + rpcId.ToString() + netId.ToString();
            mRpcExecuteHash = mRpcExecuteName .GetHashCode();
            RegisterRpcDelegate(GetType(), mRpcExecuteHash , RpcExecute);
        }
    
        public override void OnStartServer()
        {
            base.OnStartServer();
            mRpcExecuteName = "RpcExecute:" + rpcId.ToString() + netId.ToString();
            mRpcExecuteHash = mRpcExecuteName .GetHashCode();
        }
    [Command]
     public void CmdExecute() {
         mRpcExecuteWriter .StartMessage(MsgType.Rpc);
        mRpcExecuteWriter .WritePackedUInt32((uint)mRpcExecuteHash );
        mRpcExecuteWriter .Write(netId);
        //mRpcExecuteWriter .Write(some more data);
        mRpcExecuteWriter .FinishMessage();
        SendRPCInternal(mRpcExecuteWriter , 0, mRpcExecuteName );
     }

void RpcExecute(NetworkBehaviour obj, NetworkReader reader)
    {
       //read data
    }

Not the best solution, but it works for me. Thanks.