Commit 8a901a5
committed
fix: networkvariable not synchronizing changes made during spawn or post-spawn. (#3878)
* fix
Fixing the issue with the missing `OnSpawned` override within `NetworkVariable`.
* test
Adding a general test for scenarios like this one.
* update
Adding changelog entry.
* style
Adding comments for clarity of what `OnSpawned` and the call to `PostNetworkVariableWrite` is for.
Removing trailing whitespaces.
* refactor
Just apply the changes to the NetworkVariable instance and not all NetworkVariables of the NetworkBehaviour.
* style
correcting the comment.
* fix
Very similar to NetworkList (we might collapse the OnSpawned logic into NetworkVariableBase.
* test-fix
OwnerModifiedTests was not properly spawning from the non-session owner client (it was spawning with ownership on the session owner side).
NetworkVariableCollectionTests is showing an issue with changes for only the host instance and only within the TestDictionaryCollections (has to do with trying to add and then reverting vs the tracked changes).
* test
Narrowed down the issue to the changes tracked (i.e. added, removed, changed, unchanged) not matching when running a host but when comparing the actual dictionaries that all passes...
* test
Removing developer logging.
* test - fix
Fixed the issue in the `TestDictionaryCollections` test where clients that did not have the initial added target changes for server changes when running a host. Now, upon clients spawning players locally on the clients, the server write dictionary that is already populated by the host will have the added target changes injected during spawn to assure the changes match. (This is only for this specific test when running the host `TestFixture` pass.
* style
removing unused debug related script.
* update
Based on peer review, folding the same logic for spawn authority resetting dirty once spawned to assure no duplicate changes are sent.1 parent b2e11c3 commit 8a901a5
File tree
8 files changed
+247
-55
lines changed- com.unity.netcode.gameobjects
- Runtime
- Core
- NetworkVariable
- Collections
- Tests/Runtime/NetworkVariable
8 files changed
+247
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
839 | | - | |
| 839 | + | |
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
892 | | - | |
| 892 | + | |
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
| |||
Lines changed: 0 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 61 | | |
84 | 62 | | |
85 | 63 | | |
| |||
Lines changed: 19 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 143 | | |
149 | 144 | | |
150 | 145 | | |
151 | | - | |
| 146 | + | |
152 | 147 | | |
153 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
159 | | - | |
| 170 | + | |
160 | 171 | | |
161 | 172 | | |
162 | 173 | | |
163 | | - | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
| |||
Lines changed: 35 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
834 | | - | |
| 834 | + | |
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
843 | | - | |
844 | 843 | | |
845 | 844 | | |
846 | 845 | | |
| |||
852 | 851 | | |
853 | 852 | | |
854 | 853 | | |
| 854 | + | |
855 | 855 | | |
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
860 | | - | |
| 860 | + | |
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| 864 | + | |
864 | 865 | | |
865 | 866 | | |
866 | 867 | | |
| |||
892 | 893 | | |
893 | 894 | | |
894 | 895 | | |
895 | | - | |
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
| 918 | + | |
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
959 | | - | |
| 959 | + | |
960 | 960 | | |
961 | 961 | | |
962 | 962 | | |
| |||
1841 | 1841 | | |
1842 | 1842 | | |
1843 | 1843 | | |
1844 | | - | |
| 1844 | + | |
1845 | 1845 | | |
1846 | 1846 | | |
1847 | | - | |
| 1847 | + | |
1848 | 1848 | | |
1849 | 1849 | | |
1850 | 1850 | | |
| |||
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
1973 | 1985 | | |
1974 | 1986 | | |
1975 | 1987 | | |
| |||
2016 | 2028 | | |
2017 | 2029 | | |
2018 | 2030 | | |
2019 | | - | |
2020 | 2031 | | |
| 2032 | + | |
2021 | 2033 | | |
2022 | 2034 | | |
2023 | 2035 | | |
2024 | 2036 | | |
2025 | 2037 | | |
2026 | 2038 | | |
2027 | 2039 | | |
| 2040 | + | |
| 2041 | + | |
2028 | 2042 | | |
2029 | 2043 | | |
2030 | 2044 | | |
2031 | 2045 | | |
2032 | 2046 | | |
2033 | 2047 | | |
2034 | 2048 | | |
2035 | | - | |
| 2049 | + | |
2036 | 2050 | | |
2037 | 2051 | | |
2038 | 2052 | | |
2039 | 2053 | | |
2040 | 2054 | | |
2041 | 2055 | | |
2042 | 2056 | | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
2043 | 2068 | | |
2044 | 2069 | | |
2045 | 2070 | | |
| |||
0 commit comments