-
Notifications
You must be signed in to change notification settings - Fork 463
Closed
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve ittype:bugBug ReportBug Report
Description
Description
We faced problem with syncing FixedStringXBytes of the NetworkBehaviour when changing ownership of the corresponding NetworkObject
There are no probmlems with other supported type (float, bool, INetworkSerializable struct)
Reproduce Steps
- Add next component to the project:
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
public class Sample : NetworkBehaviour
{
[SerializeField] private NetworkVariable<FixedString64Bytes> _string1 = new NetworkVariable<FixedString64Bytes>(string.Empty);
[SerializeField] private NetworkVariable<FixedString64Bytes> _string2 = new NetworkVariable<FixedString64Bytes>(string.Empty);
public override void OnNetworkSpawn()
{
if(IsServer)
{
_string1.Value = "QWERTY";
_string2.Value = "QWERTYASDFG";
}
}
}- Add this component to any
NetworkObjecton scene - Start Host/Server (optionaly connect with a few clients; clients count doesn't matter)
- Change the ownership of the object (you can use server itself as an argument)
- Observe
OverflowException: Attempted to write without first calling TryBeginWrite()each frame
Actual Outcome
Error each frame on server side:
OverflowException: Attempted to write without first calling TryBeginWrite()
Unity.Netcode.FastBufferWriter.WriteByte (System.Byte value) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Serialization/FastBufferWriter.cs:655)
Unity.Netcode.FixedStringSerializer`1[T].WriteDelta (Unity.Netcode.FastBufferWriter writer, T& value, T& previousValue) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/NetworkVariable/NetworkVariableSerialization.cs:720)
Unity.Netcode.NetworkVariableSerialization`1[T].WriteDelta (Unity.Netcode.FastBufferWriter writer, T& value, T& previousValue) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/NetworkVariable/NetworkVariableSerialization.cs:1642)
Unity.Netcode.NetworkVariable`1[T].WriteDelta (Unity.Netcode.FastBufferWriter writer) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/NetworkVariable/NetworkVariable.cs:198)
Unity.Netcode.NetworkVariableDeltaMessage.Serialize (Unity.Netcode.FastBufferWriter writer, System.Int32 targetVersion) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs:111)
Unity.Netcode.NetworkBehaviour.NetworkVariableUpdate (System.UInt64 targetClientId, System.Int32 behaviourIndex) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkBehaviour.cs:909)
Unity.Netcode.NetworkBehaviour.VariableUpdate (System.UInt64 targetClientId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkBehaviour.cs:860)
Unity.Netcode.NetworkBehaviourUpdater.NetworkBehaviourUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkBehaviourUpdater.cs:57)
Unity.Netcode.NetworkBehaviourUpdater.NetworkBehaviourUpdater_Tick () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkBehaviourUpdater.cs:129)
Unity.Netcode.NetworkTickSystem.UpdateTick (System.Double localTimeSec, System.Double serverTimeSec) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Timing/NetworkTickSystem.cs:102)
Unity.Netcode.NetworkTimeSystem.UpdateTime () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Timing/NetworkTimeSystem.cs:141)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkManager.cs:57)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkUpdateLoop.cs:192)
Unity.Netcode.NetworkUpdateLoop+NetworkPreUpdate+<>c.<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/Core/NetworkUpdateLoop.cs:239)
Expected Outcome
Same behaviour as for other supported types
Environment
- OS: Windows 10
- Unity Version: 2023.2.18f1
- Netcode Version: 1.9.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve ittype:bugBug ReportBug Report