-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
@@ -32,7 +32,14 @@ internal class AcademyFixedUpdateStepper : MonoBehaviour | |||
{ | |||
void FixedUpdate() | |||
{ | |||
Academy.Instance.EnvironmentStep(); | |||
if (!Academy.IsStepperOwner(this)) |
There was a problem hiding this comment.
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:
- Make IsStepperOwner() non-static again
- 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)) |
There was a problem hiding this comment.
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?
* run devproject tests * loosen trigger for testing * reset Academy at start of test * redo trigger, add comment
…chnologies/ml-agents into develop-cleanup-stepper
There was a problem hiding this 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>
Updated in the summary |
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)
Checklist
Other comments