Skip to content

SyncList callbacks: itemIndex is always 0 #3354

@miwarnec

Description

@miwarnec

from discord.
https://discord.com/channels/343440455738064897/883289312299475014/1062768523438469260

using the following script on Tanks.cs demo

        readonly SyncList<int> list = new SyncList<int>();

        void Awake()
        {
            list.Callback += OnChanged;
        }

        public override void OnStartServer()
        {
            InvokeRepeating(nameof(AddOne), 3, 3);
        }

        void AddOne()
        {
            list.Add(list.Count);
        }

        void OnChanged(SyncList<int>.Operation op, int index, int oldItem, int newItem)
        {
            Debug.LogWarning($"SyncList OnChanged index={index} old={oldItem} new={newItem}");
        }

list.add works:
2023-01-12 - 00-27-30@2x

changing list after adding seems to break the index:
2023-01-12 - 00-30-17@2x

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions