浏览代码

comments

/bug-failed-api-check
Chris Elion 5 年前
当前提交
d84e80ed
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 5
      com.unity.ml-agents/Runtime/SideChannels/OutgoingMessage.cs
  2. 2
      com.unity.ml-agents/Tests/Editor/SideChannelTests.cs

5
com.unity.ml-agents/Runtime/SideChannels/OutgoingMessage.cs


/// <param name="data"></param>
public void SetRawBytes(byte[] data)
{
// Reset first.
// Reset first. Set the length to zero so that if there's more data than we're going to
// write, we don't have any of the original data.
// Then append the data
// Then append the data. Increase the capacity if needed (but don't shrink it).
m_Stream.Capacity = (m_Stream.Capacity < data.Length) ? data.Length : m_Stream.Capacity;
m_Stream.Write(data, 0, data.Length);
}

2
com.unity.ml-agents/Tests/Editor/SideChannelTests.cs


[Test]
public void TestOutgoingMessageRawBytes()
{
// Make sure that SetRawBytes resets the buffer correctly.
// Write 8 bytes (an int and float) then call SetRawBytes with 4 bytes
var msg = new OutgoingMessage();
msg.WriteInt32(42);
msg.WriteFloat32(1.0f);

正在加载...
取消
保存