-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
chriselion
commented
Feb 6, 2020
- 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
Assert.IsTrue(aca.IsAutomaticSteppingEnabled); | ||
Assert.IsTrue(aca.AutomaticSteppingEnabled); | ||
|
||
// Note that calling |
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.
@surfnerd Thoughts on this? I assume Object.Destroy() is generally preferable, but unit tests break if we do that instead of Object.DestroyImmediate()
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.
Seems good since it's false
by default.
} | ||
else | ||
{ | ||
DisableAutomaticStepping(); |
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.
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 ?
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.
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.
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.
What is wrong having DestroyImmediate be the only option?
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.
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);
}
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.
DestroyImmediate is strongly recommended against since it tries to deallocate memory immediately instead of batching it together after a normal Destroy call.
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.
Should we make DisableAutomaticStepping
internal (This way we can test it without exposing it?)
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.
DisableAutomaticStepping is now private; I use Application.isEditor to switch between Destroy and DestoryImmediate.