'How can I pass rgb color to OnPhotonSerializeView (Photon Network)

I need to pass rgb variables to OnPhotonSerializeView.

I tried to do it like this:

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
    if (stream.IsWriting)
    {
        stream.SendNext(healthCircle.color.r);
        stream.SendNext(healthCircle.color.g);
        stream.SendNext(healthCircle.color.b);
    }
    else 
    {
        healthCircle.color.r = (float)stream.ReceiveNext();
        healthCircle.color.g = (float)stream.ReceiveNext();
        healthCircle.color.b = (float)stream.ReceiveNext();
    }
}

After this i get an error:

Assets\Scripts\Player.cs(68,13): error CS1612: Cannot modify the return value of 'SpriteRenderer.color' because it is not a variable

I tried to search it in google but i didn't find anything. Sorry for my noob question. Waiting for your help :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source