- Home /
Light.color Sync ?
i'm trying to sync Light color between player always i got error
Exception: cannot serialize(): UnityEngine.Color ExitGames.Client.Photon.Protocol16.Serialize
i did like this
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(PhotonView))]
public class LightColorNetwork : Photon.MonoBehaviour
{
public Light HeadLights;
private Color LightColor;
public void FixedUpdate ()
{
// If we are not owner receive all inputs from server.
if (!photonView.isMine)
{
HeadLights.color = LightColor;
}
private void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info)
{
// Sending all inputs to server.
if (stream.isWriting)
{
stream.SendNext(HeadLights.color);
}
else
{
LightColor = (Color)stream.ReceiveNext();
updateTime = Time.time;
}
}
}
Thanks in advance for any help!
Answer by ChristianSimon · Dec 21, 2017 at 09:08 AM
Hi,
in order to synchronize a Color type you either have to send each single RGBA value as float or have to register a Custom Type. To see how this works I would recommend you taking a look at the Serialization in Photon documentation pages which contains an easy to understand example of how Vector2 is serialized by PUN. You can adjust this for Color types.
Your answer
Follow this Question
Related Questions
Why does Photon find a room so quick! 1 Answer
Photon network won't join random room with a custom property 0 Answers
Setting up a GUI System for room selection , Multiplayer (Photon/Unet) 1 Answer
Callback for DNS entry error using Photon Networking 0 Answers
Player Smoothness across network (PUN) 0 Answers