浏览代码

Fix NullReferenceException for Behavior Parameters without Agent (#5382)

* check agent existence. add warning box

* changelog
/colab-links
GitHub 4 年前
当前提交
d771d99c
共有 2 个文件被更改,包括 15 次插入0 次删除
  1. 1
      com.unity.ml-agents/CHANGELOG.md
  2. 14
      com.unity.ml-agents/Editor/BehaviorParametersEditor.cs

1
com.unity.ml-agents/CHANGELOG.md


### Major Changes
### Minor Changes
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
- Fixed NullReferenceException when adding Behavior Parameters with no Agent. (#5382)
#### ml-agents / ml-agents-envs / gym-unity (Python)
- Added a fully connected visual encoder for environments with very small image inputs. (#5351)
### Bug Fixes

14
com.unity.ml-agents/Editor/BehaviorParametersEditor.cs


so.Update();
bool needPolicyUpdate; // Whether the name, model, inference device, or BehaviorType changed.
var behaviorParameters = (BehaviorParameters)target;
var agent = behaviorParameters.gameObject.GetComponent<Agent>();
if (agent == null)
{
EditorGUILayout.HelpBox(
"No Agent is associated with this Behavior Parameters. Attach an Agent to " +
"this GameObject to configure your Agent with these behavior parameters.",
MessageType.Warning);
}
// Drawing the Behavior Parameters
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck(); // global

// Grab the sensor components, since we need them to determine the observation sizes.
// TODO make these methods of BehaviorParameters
var agent = behaviorParameters.gameObject.GetComponent<Agent>();
if (agent == null)
{
return;
}
agent.sensors = new List<ISensor>();
agent.InitializeSensors();
var sensors = agent.sensors.ToArray();

正在加载...
取消
保存