SyncVars could be any Unity asset type, such as Texture, Material, Sprite, Shader, Light…
As long as they are registered at runtime on the client, they can be sent from the server to clients. This applies to parameters in ClientRpc calls as well.
public class Player : NetworkBehaviour
{
[SyncVar(hook="OnMat")]
Material mat;
void OnMat(Material m)
{
GetComponent<Renderer>().material = m;
mat = m;
}
public Material otherMaterial;
void Awake()
{
ClientScene.RegisterAsset(otherMaterial);
}
public override void OnStartClient()
{
if (mat != null)
GetComponent<Renderer>().material = mat;
}
[ClientRpc]
void RpcSetMaterial(Material mat)
{
GetComponent<Renderer>().material = mat;
}
}
ah… but that misconception is one reason not to do this. Passing a component such as a Transform would pass by reference, not by value. So the other end would get a reference to its local instance of the transform with the local values, not the values from the source object.
Looks very UE4-ish but I don’t understand the example. You have SyncVar on mat, but it’s not being modified anywhere else other than the hook? The asset that is registered is otherMaterial but that’s not being used anywhere. The RPC is setup but what’s the typical call to the RPC look like?