Skip to content

deregister the same method we registered #3072

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

Merged
merged 1 commit into from
Dec 12, 2019

Conversation

chriselion
Copy link
Contributor

Currently we add one method in OnEnableHelper() but remove another in OnDisable()

academy.AgentForceReset += _AgentReset;
m_PolicyFactory = GetComponent<BehaviorParameters>();
m_Brain = m_PolicyFactory.GeneratePolicy(Heuristic);
ResetData();
InitializeAgent();
InitializeSensors();
}
/// Monobehavior function that is called when the attached GameObject
/// becomes disabled or inactive.
void OnDisable()
{
var academy = FindObjectOfType<Academy>();
if (academy != null)
{
academy.AgentSetStatus -= SetStatus;
academy.AgentResetIfDone -= ResetIfDone;
academy.AgentSendState -= SendInfo;
academy.DecideAction -= DecideAction;
academy.AgentAct -= AgentStep;
academy.AgentForceReset -= ForceReset;

The original intent was probably to add ForceReset(), but to keep behavior consistent, we'll remove _AgentReset() instead

@chriselion chriselion merged commit 4a36bd4 into master Dec 12, 2019
@delete-merged-branch delete-merged-branch bot deleted the develop-MLA-423-Agent.ForceReset branch December 12, 2019 01:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants