What is the proper way to extend SyncList<T>?

I implemented a custom SyncList, following the examples of the built-in SyncListUInt, etc…

However, it’s not working correctly. Adding new items on server will not push the changes to clients. Also as a sidenote, SyncList.AddInternal() is marked internal. If we are to extend SyncList, are we forced to use Add() instead?

    public class SyncListEHero : SyncList<EHero>  //EHero is an enum
    {
        protected override void SerializeItem(NetworkWriter writer, EHero item)
        {
            writer.WritePackedUInt32((uint)item);
        }

        protected override EHero DeserializeItem(NetworkReader reader)
        {
            return (EHero)reader.ReadPackedUInt32();
        }

        public static SyncListEHero ReadInstance(NetworkReader reader)
        {
            ushort num = reader.ReadUInt16();
            SyncListEHero syncList = new SyncListEHero();
            for (ushort index = (ushort)0; (int)index < (int)num; ++index)
                syncList.Add((EHero)reader.ReadPackedUInt32());
            return syncList;
        }

        public static void WriteInstance(NetworkWriter writer, SyncListEHero items)
        {
            writer.Write((ushort)items.Count);
            foreach (var num in (SyncList<EHero>)items)
                writer.WritePackedUInt32((uint)num);
        }
    }

I tested it with the following code. “asdasd”, Tyrion, and 999 show up fine on the server. However on the client, only “asdasd” and 999 show through.

    public class SharedInfo : NetworkBehaviour {

        public SyncListEHero AvailableHeroes = new SyncListEHero();
        public SyncListString TestStringList = new SyncListString();

        [SyncVar]
        public int Test;

        void Start()
        {
            if (isServer)
            {
                TestStringList.Add("asdasd");
                AvailableHeroes.Add(EHero.Tyrion);
                Test = 999;
            }
        }

    }

sadly, user code cannot extent SyncList<> at the moment. There are custom hooks in the code generator for the types it supports. User-defined enum types are problematic with these custom hooks in the current implementation, so SyncListEnum is not supported.

Got you, I see you what you mean. Thanks for the clarification.

Custom SyncList are convenient but not too important. So take your time with it.