Netcode for GameObjects同步昵称时间积分,一直数据溢出,
试过很多办法了,ai也用了解决不了,官方文档也看了。。我还看了官方项目,一模一样写,人家可以我就是不行,,我现在简化了就昵称,还是不行呀。。Netcode for GameObjects卸载了在重新下载了
OverflowException: Reading past the end of the buffer
namespace Unity.Multiplayer.Samples.BossRoom
{
public class PlayerNetworkState : NetworkBehaviour
{
public NetworkVariable<FixedPlayerName> PlayerName = new NetworkVariable<FixedPlayerName>();
public void InitializePlayer(string username)
{
if (IsServer)
{
PlayerName.Value = username;
}
}
}
public struct FixedPlayerName : INetworkSerializable
{
FixedString32Bytes m_Name;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref m_Name);
}
public override string ToString()
{
return m_Name.Value.ToString();
}
public static implicit operator string(FixedPlayerName s) => s.ToString();
public static implicit operator FixedPlayerName(string s) => new FixedPlayerName() { m_Name = new FixedString32Bytes(s) };
}
}
试过很多办法了,ai也用了解决不了,官方文档也看了。。我还看了官方项目,一模一样写,人家可以我就是不行,,我现在简化了就昵称,还是不行呀。。Netcode for GameObjects卸载了在重新下载了
OverflowException: Reading past the end of the buffer
namespace Unity.Multiplayer.Samples.BossRoom
{
public class PlayerNetworkState : NetworkBehaviour
{
public NetworkVariable<FixedPlayerName> PlayerName = new NetworkVariable<FixedPlayerName>();
public void InitializePlayer(string username)
{
if (IsServer)
{
PlayerName.Value = username;
}
}
}
public struct FixedPlayerName : INetworkSerializable
{
FixedString32Bytes m_Name;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref m_Name);
}
public override string ToString()
{
return m_Name.Value.ToString();
}
public static implicit operator string(FixedPlayerName s) => s.ToString();
public static implicit operator FixedPlayerName(string s) => new FixedPlayerName() { m_Name = new FixedString32Bytes(s) };
}
}