Below is a fragment of my code where the Rpc is called.
You can see that I am doing some extra checks to make sure that the parameter being passed is not null by making a new copy of the dictionary I want to pass and then adding a value and to top it off a quick log so I can see in the editor there’s no funny business.
Dictionary<int, float> parameter = new Dictionary<int, float>(resources);
if(parameter != null)
Debug.Log("resources != null");
else
Debug.Log("resources == null");
parameter.Add(1, 4.3f);
if(networkController.isServer)
{
networkController.RpcSendRList(parameter);
}
When running this as the server or the client, parameter
is logged as not being null before I even add the KeyValuePair<int, float>
of (1, 4.3f)
, so I’m sure parameter
is not null.
Below are the Rpcs being called:
[ClientRpc]
public void RpcSendRList(Dictionary<int, float> _rList)
{
if(_rList != null)
opponentResources = _rList;
else
Debug.Log("null dict");
}
The result in the editor is that it logs “null dict”.
I have debugged this function by putting a breakpoint in just so I can be sure when reading the _rList
parameter that it is null and indeed the result is null.
If I have logged the value before as to not be null then why is it being received as null by the client?