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

Clean up AcademyFixedUpdateStepper when playmode changed #4532

Merged
merged 18 commits into from
Oct 7, 2020

Conversation

dongruoping
Copy link
Contributor

@dongruoping dongruoping commented Oct 1, 2020

Proposed change(s)

Clean up AcademyFixedUpdateStepper when playmode changed. Also add insurance check in stepper to delete itself if it's not the stepper of current Academy.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Fixing issue reported in #4521 .
JIRA ticket: https://jira.unity3d.com/browse/MLA-1410

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@dongruoping dongruoping requested a review from chriselion October 1, 2020 22:11
@dongruoping dongruoping requested a review from chriselion October 2, 2020 17:55
@@ -32,7 +32,14 @@ internal class AcademyFixedUpdateStepper : MonoBehaviour
{
void FixedUpdate()
{
Academy.Instance.EnvironmentStep();
if (!Academy.IsStepperOwner(this))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be a little more careful here with how you access the Academy instance so that we don't create a new one accidentally. I'd recommend:

  1. Make IsStepperOwner() non-static again
  2. In FixedUpdate(), either do nothing if the Academy isn't initialized, or call Destroy() (but avoid the call to IsStepperOwner).

@@ -32,7 +32,14 @@ internal class AcademyFixedUpdateStepper : MonoBehaviour
{
void FixedUpdate()
{
Academy.Instance.EnvironmentStep();
if (!Academy.IsStepperOwner(this))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can you add some comments on why this is necessary?

Chris Elion and others added 3 commits October 6, 2020 17:33
* run devproject tests

* loosen trigger for testing

* reset Academy at start of test

* redo trigger, add comment
Copy link
Contributor

@chriselion chriselion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit on the changelog.

Can you also put a link to the jira issue in the PR summary?

Otherwise looks good!

Co-authored-by: Chris Elion <chris.elion@unity3d.com>
@dongruoping
Copy link
Contributor Author

Can you also put a link to the jira issue in the PR summary?

Updated in the summary

dongruoping added a commit that referenced this pull request Nov 10, 2020
chriselion pushed a commit that referenced this pull request Nov 11, 2020
* bring in bugfix from #4532

* add meta files

* remove extra file

* update yamato tests

* use v2 action and pin python version (#4568)

* update changelog

Co-authored-by: Chris Elion <chris.elion@unity3d.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants