It looks like you need an object on the server to set myColor for each client.
//In a NetworkManager-derived script
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) {
base.OnServerAddPlayer(conn, playerControllerId);
GameObject player = null;
PlayerController playerController = null;
if (conn.GetPlayerController(playerControllerId, out playerController)) {
player = playerController.gameObject;
}
if (player != null) {
var playersyncer = player.GetComponent<ColorSync>();
playersyncer.myColor = RandomEx.RandomColor();
}
}
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) {
base.OnServerAddPlayer(conn, playerControllerId);
if(conn.playerControllers.Count > 0){
GameObject player = conn.playerControllers [0].gameObject;
// do stuff to the player GameObject
}
}
This is assuming that you’ll only ever have 1 player per connection. If there are more, then just loop through the list…