浏览代码

Fix GridSensorComponent bug (#5270)

/check-for-ModelOverriders
GitHub 4 年前
当前提交
8d11e68d
共有 2 个文件被更改,包括 16 次插入1 次删除
  1. 2
      com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs
  2. 15
      com.unity.ml-agents/Tests/Runtime/Sensor/GridSensorTests.cs

2
com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs


/// <inheritdoc/>
public override ISensor[] CreateSensors()
{
List<ISensor> m_Sensors = new List<ISensor>();
m_Sensors = new List<ISensor>();
m_BoxOverlapChecker = new BoxOverlapChecker(
m_CellScale,
m_GridSize,

15
com.unity.ml-agents/Tests/Runtime/Sensor/GridSensorTests.cs


#if MLA_UNITY_PHYSICS_MODULE
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

LogAssert.Expect(LogType.Warning, $"Compression type {SensorCompressionType.PNG} is only supported with normalized data. " +
"The sensor will not compress the data.");
Assert.AreEqual(gridSensor.CompressionType, SensorCompressionType.None);
}
[Test]
public void TestCreateSensor()
{
testGo.tag = k_Tag2;
string[] tags = { k_Tag1, k_Tag2 };
gridSensorComponent.SetComponentParameters(tags, useGridSensorBase: true);
gridSensorComponent.CreateSensors();
var componentSensor = (List<ISensor>)typeof(GridSensorComponent).GetField("m_Sensors",
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gridSensorComponent);
Assert.AreEqual(componentSensor.Count, 1);
}
[Test]

正在加载...
取消
保存