Skip to content

Academy interface cleanup #3376

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 4 commits into from
Feb 7, 2020
Merged

Conversation

chriselion
Copy link
Contributor

  • Academy.LazyInitialization -> LazyInitialize (this was internal)
  • Academy.IsAutomaticSteppingEnabled -> AutomaticSteppingEnabled and add setter. EnableAutomaticStepping made internal (DisableAutomaticStepping still public because is has an advanced option).
  • Academy.GetEpisodeCount, GetStepCount, GetTotalStepCount ->EpisodeCount, StepCount, TotalStepCount properties

@chriselion chriselion changed the title Develop academy interface cleanup Academy interface cleanup Feb 6, 2020
Assert.IsTrue(aca.IsAutomaticSteppingEnabled);
Assert.IsTrue(aca.AutomaticSteppingEnabled);

// Note that calling
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@surfnerd Thoughts on this? I assume Object.Destroy() is generally preferable, but unit tests break if we do that instead of Object.DestroyImmediate()

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems good since it's false by default.

}
else
{
DisableAutomaticStepping();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is DisableAutomaticStepping still public? Seems like there are now 2 ways to disable stepping

AutomaticSteppingEnabled = false;

and

DisableAutomaticStepping()

If it is to leave the option to destroy immediate or not, why do we need to be able to do both ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the comments above:

I assume Object.Destroy() is generally preferable, but unit tests break if we do that instead of Object.DestroyImmediate()

Open to other suggestions on how to resolve this.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is wrong having DestroyImmediate be the only option?

Copy link
Contributor

@vincentpierre vincentpierre Feb 7, 2020

Choose a reason for hiding this comment

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

Or we could have this in the test :

        [Test]
        public void TestAcademyAutostep()
        {
            var aca = Academy.Instance;
            Assert.IsTrue(aca.IsAutomaticSteppingEnabled);
            UnityEngine.TestTools.LogAssert.Expect(LogType.Error, "Destroy may not be called from edit mode! Use DestroyImmediate instead.\nAlso think twice if you really want to destroy something in edit mode. Since this will destroy objects permanently.");
            aca.DisableAutomaticStepping(false);
            Assert.IsFalse(aca.IsAutomaticSteppingEnabled);
            aca.EnableAutomaticStepping();
            Assert.IsTrue(aca.IsAutomaticSteppingEnabled);
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

DestroyImmediate is strongly recommended against since it tries to deallocate memory immediately instead of batching it together after a normal Destroy call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make DisableAutomaticStepping internal (This way we can test it without exposing it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DisableAutomaticStepping is now private; I use Application.isEditor to switch between Destroy and DestoryImmediate.

@chriselion chriselion merged commit 1d23994 into master Feb 7, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-Academy-interface-cleanup branch February 7, 2020 21:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 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.

3 participants