Closed harayuu9 closed 3 weeks ago
It doesn’t seem to be an issue with the Dirty flag not being set; rather, it appears to be a problem with WriteDelta in ListSerializer not writing correctly. As an experiment, I replaced WriteDelta with Write(writer, ref value);
and similarly modified the Read method, which resolved the issue. Since you have to manually set the Dirty flag for Lists, I still recommend using the Managed version of NetworkList.
@harayuu9
I believe the updates in that PR will resolve the issue you are experiencing with using NetworkVariable<List<Class>>
.
@NoelStephensUnity Thank you, I'll check it out when it's backported.
I tried the new version(2.xx) and it was fixed. Thank you.
Title
WriteDelta does not work correctly for
NetworkVariable<List<Class>>
due to incorrect handling of duplicates inListSerializer
Description
The
Duplicate
method in theListSerializer
does not make copies of the instances within the list. As a result, when the number of elements in the list changes, it marks the list as Dirty correctly, but changes to the contents of the class instances within the list do not trigger the Dirty state.The
Class
in question implementsINetworkSerializable
andIEquatable
as expected, so this behavior is unexpected. Since a simple solution isn’t apparent, I recommend adding a managed version ofNetworkList
. Additionally, implementing an ILPP error for cases like this would be beneficial.Reproduce Steps
NetworkVariable<List<Class>>
.Actual Outcome
Modifying the properties of instances within the list does not trigger
WriteDelta
, and the list does not enter the Dirty state.Expected Outcome
Modifying the properties of instances within the list should trigger the Dirty state for the list as a whole.
Screenshots
(If applicable, add screenshots to help explain your problem)
Environment
Additional Context
Additional context related to the problem is provided below.
Please include logs or code snippets, and if possible, attach a minimal Unity project that reproduces the issue.