/// <inheritdoc/>
        public override ISensor[] CreateSensors()
        {
            DetectableGameObject.ClearCache();
            ValidateGameObjectSettings();

            if (m_GameObjectSettingsMeta.DetectableTags.Count > 0)
            {
                // Unlike GridSensorComponentBase, this component creates its own GridBuffer.
                // We use a ColorGridBuffer in order to support PNG compression.
                // GridShape is set by the 2D and 3D subcomponents prior to creating the buffer.
                GridBuffer = new ColorGridBuffer(GridShape);

                var sensors = base.CreateSensors();

                if (Application.isPlaying)
                {
                    // TODO It should be clearer which sensor features are enabled
                    // in editor vs play mode. Detector/Encoder code is supposed to
                    // be runtime only.
                    m_GridSensor.EnableAutoDetection(CreateDetector(), CreateEncoder());
                }

                return(sensors);
            }

            throw new UnityAgentsException("No detectable tags found! " +
                                           "Add a detectable gameobject to the inspector settings.");
        }
Exemplo n.º 2
0
 public override void Reset()
 {
     if (m_ClearCacheOnReset)
     {
         DetectableGameObject.ClearCache();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Invoked on sensor reset at the end of each episode.
 /// </summary>
 public void OnSensorReset()
 {
     if (m_ClearCacheOnReset)
     {
         DetectableGameObject.ClearCache();
     }
 }