您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
47 行
1.5 KiB
47 行
1.5 KiB
using UnityEngine;
|
|
|
|
namespace MLAgents.Sensors
|
|
{
|
|
/// <summary>
|
|
/// Component that wraps a <see cref="RenderTextureSensor"/>.
|
|
/// </summary>
|
|
[AddComponentMenu("ML Agents/Render Texture Sensor", (int)MenuGroup.Sensors)]
|
|
public class RenderTextureSensorComponent : SensorComponent
|
|
{
|
|
/// <summary>
|
|
/// The <see cref="RenderTexture"/> instance that the associated
|
|
/// <see cref="RenderTextureSensor"/> wraps.
|
|
/// </summary>
|
|
public RenderTexture renderTexture;
|
|
|
|
/// <summary>
|
|
/// Name of the sensor.
|
|
/// </summary>
|
|
public string sensorName = "RenderTextureSensor";
|
|
|
|
/// <summary>
|
|
/// Whether the RenderTexture observation should be converted to grayscale or not.
|
|
/// </summary>
|
|
public bool grayscale;
|
|
|
|
/// <summary>
|
|
/// Compression type for the render texture observation.
|
|
/// </summary>
|
|
public SensorCompressionType compression = SensorCompressionType.PNG;
|
|
|
|
/// <inheritdoc/>
|
|
public override ISensor CreateSensor()
|
|
{
|
|
return new RenderTextureSensor(renderTexture, grayscale, sensorName, compression);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override int[] GetObservationShape()
|
|
{
|
|
var width = renderTexture != null ? renderTexture.width : 0;
|
|
var height = renderTexture != null ? renderTexture.height : 0;
|
|
|
|
return new[] { height, width, grayscale ? 1 : 3 };
|
|
}
|
|
}
|
|
}
|