Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BehaviorParametersEditor OnInspectorGUI constantly recreates sensors #5443

Closed
mbaske opened this issue Jun 27, 2021 · 5 comments
Closed

BehaviorParametersEditor OnInspectorGUI constantly recreates sensors #5443

mbaske opened this issue Jun 27, 2021 · 5 comments
Assignees
Labels
bug Issue describes a potential bug in ml-agents. stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long.

Comments

@mbaske
Copy link

mbaske commented Jun 27, 2021

BehaviorParametersEditor's OnInspectorGUI() calls DisplayFailedModelChecks(), which then calls agent.InitializeSensors(). This causes the CreateSensors() code to be invoked on every OnInspectorGUI callback, even at runtime. The only way to stop repeated sensor instantiation is to hide the BehaviorParameters component inspector, so that its GUI is no longer updated.

To Reproduce
Open the FoodCollector example and place a Debug.Log in GridSensorComponent's CreateSensors() method. Select one of the agent gameobjects in the hierarchy and fold out its behavior parameters inspector settings. Enter play mode.

  • ML-Agents version: Release 18
  • Environment: FoodCollector
@mbaske mbaske added the bug Issue describes a potential bug in ml-agents. label Jun 27, 2021
@mbaske
Copy link
Author

mbaske commented Jun 28, 2021

Here's my workaround for hiding the inspector:

if (Application.isPlaying)
{
    var tracker = UnityEditor.ActiveEditorTracker.sharedTracker;
    var editors = tracker.activeEditors;
    for (int i = 0; i < editors.Length; i++)
    {
        // Can't check type because BehaviorParametersEditor is internal.
        if (editors[i].ToString() == " (Unity.MLAgents.Editor.BehaviorParametersEditor)")
        {
            tracker.SetVisible(i, 0);
        }
    }
}

@ervteng
Copy link
Contributor

ervteng commented Jun 28, 2021

Thanks for reporting this bug - i've recorded it in our internal tracker as MLA-2093, and it should be fixed in an upcoming release.

@ervteng ervteng self-assigned this Jun 28, 2021
@hvpeteet hvpeteet assigned sini and unassigned ervteng Nov 4, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had activity in the last 28 days. It will be closed in the next 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long. label Jan 9, 2022
@stale
Copy link

stale bot commented Apr 19, 2022

This issue has been automatically closed because it has not had activity in the last 42 days. If this issue is still valid, please ping a maintainer. Thank you for your contributions.

@stale stale bot closed this as completed Apr 19, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue describes a potential bug in ml-agents. stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long.
Projects
None yet
Development

No branches or pull requests

3 participants