File tree 3 files changed +30
-3
lines changed
UnitySDK/Assets/ML-Agents
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ public override void OnInspectorGUI()
33
33
EditorGUILayout . PropertyField ( so . FindProperty ( "m_InferenceDevice" ) , true ) ;
34
34
EditorGUI . indentLevel -- ;
35
35
EditorGUILayout . PropertyField ( so . FindProperty ( "m_BehaviorType" ) ) ;
36
+ EditorGUILayout . PropertyField ( so . FindProperty ( "m_useChildSensors" ) , true ) ;
36
37
// EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Heuristic"), true);
37
38
EditorGUI . indentLevel -- ;
38
39
if ( EditorGUI . EndChangeCheck ( ) )
@@ -58,7 +59,15 @@ void DisplayFailedModelChecks()
58
59
Model barracudaModel = null ;
59
60
var model = ( NNModel ) serializedObject . FindProperty ( "m_Model" ) . objectReferenceValue ;
60
61
var behaviorParameters = ( BehaviorParameters ) target ;
61
- var sensorComponents = behaviorParameters . GetComponents < SensorComponent > ( ) ;
62
+ SensorComponent [ ] sensorComponents ;
63
+ if ( behaviorParameters . useChildSensors )
64
+ {
65
+ sensorComponents = behaviorParameters . GetComponentsInChildren < SensorComponent > ( ) ;
66
+ }
67
+ else
68
+ {
69
+ sensorComponents = behaviorParameters . GetComponents < SensorComponent > ( ) ;
70
+ }
62
71
var brainParameters = behaviorParameters . brainParameters ;
63
72
if ( model != null )
64
73
{
Original file line number Diff line number Diff line change @@ -496,7 +496,16 @@ public virtual float[] Heuristic()
496
496
public void InitializeSensors ( )
497
497
{
498
498
// Get all attached sensor components
499
- var attachedSensorComponents = GetComponents < SensorComponent > ( ) ;
499
+ SensorComponent [ ] attachedSensorComponents ;
500
+ if ( m_PolicyFactory . useChildSensors )
501
+ {
502
+ attachedSensorComponents = GetComponentsInChildren < SensorComponent > ( ) ;
503
+ }
504
+ else
505
+ {
506
+ attachedSensorComponents = GetComponents < SensorComponent > ( ) ;
507
+ }
508
+
500
509
sensors . Capacity += attachedSensorComponents . Length ;
501
510
foreach ( var component in attachedSensorComponents )
502
511
{
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace MLAgents
6
6
{
7
7
8
8
/// <summary>
9
- /// The Factory to generate policies.
9
+ /// The Factory to generate policies.
10
10
/// </summary>
11
11
public class BehaviorParameters : MonoBehaviour
12
12
{
@@ -34,12 +34,21 @@ private enum BehaviorType
34
34
[ HideInInspector ]
35
35
[ SerializeField ]
36
36
string m_BehaviorName = "My Behavior" ;
37
+ [ HideInInspector ]
38
+ [ SerializeField ]
39
+ [ Tooltip ( "Use all Sensor components attached to child GameObjects of this Agent." ) ]
40
+ bool m_useChildSensors = true ;
37
41
38
42
public BrainParameters brainParameters
39
43
{
40
44
get { return m_BrainParameters ; }
41
45
}
42
46
47
+ public bool useChildSensors
48
+ {
49
+ get { return m_useChildSensors ; }
50
+ }
51
+
43
52
public string behaviorName
44
53
{
45
54
get { return m_BehaviorName ; }
You can’t perform that action at this time.
0 commit comments