InvalidProgramException: Invalid IL code in MyNetworkPlayer:SetDisplayName (string): IL_000f: call 0x0a00000a
This error pops up every time I try to Host(Server + Client) from the unity editor, and my name isn’t being set. Up until this point everything was working properly. The error points to the line in MyNetworkManager where I’m calling SetDisplayName on the player. I’m using the current release of mirror, 30.5.0. Below is the code:
using UnityEngine;
using Mirror;
public class MyNetworkManager : NetworkManager
{
public override void OnServerAddPlayer(NetworkConnection conn)
{
base.OnServerAddPlayer(conn);
MyNetworkPlayer player = conn.identity.GetComponent<MyNetworkPlayer>();
player.SetDisplayName($"Player {numPlayers}");
}
}
using UnityEngine;
using Mirror;
public class MyNetworkPlayer : NetworkBehaviour
{
[SyncVar]
[SerializeField]
private string displayName = "Missing Name";
[Server]
public void SetDisplayName(string newDisplayName)
{
displayName = newDisplayName;
}
}
Since this is an example project I’ll just keep going on with the course ignoring it for now, but I’m scared this problem might persist later on. Could this be a problem with the package version/unity version?