Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to correct create a SyncListColor

Discussion in 'Multiplayer' started by LootlabGames, Mar 25, 2018.

  1. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    I am having some trouble trying to sync a list of colors.

    I use the following code and everything works great but the values are never synced.
    I am using other SyncLists on the object without a problem.
    This is the only one not being synced.

    I must be missing something as I have never created a custom SyncList before.
    Here is the code:


    public class SyncListColor : SyncList<Color>
    {
    protected override void SerializeItem(NetworkWriter writer, Color color)
    {
    writer.Write(color);
    }

    protected override Color DeserializeItem(NetworkReader reader)
    {
    return reader.ReadColor();
    }
    }
     
  2. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    340
    I solved this using SyncListStruct instead.