-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
BT window shows all tasks as inactive when EditorApplication.isPaused #94
Comments
Yeah this is a feature I've thought about adding for a while. Being able to see the graph highlights in the pause state would be super useful. Definitely was annoying for me when I was working on a game recently and I needed to pause. Your solution looks pretty solid. Next time I'm working on Fluid BT I need to do a bundle of small patches and features (will include this and get you a credit). It might be a little bit of time before I get to this but it should happen eventually. |
@JeremyVansnick Appreciate this contribution, just getting started with this package and ran into this issue pretty quickly while trying to learn things. Made you're proposed modifications and it's working great 👍 |
@allcontributors add @JeremyVansnick for code |
I've put up a pull request to add @JeremyVansnick! 🎉 |
@JeremyVansnick I implemented the pause functionality. Works amazingly well!!! There was was performance bug I found double polling the fader but I fixed it. Will go out here shortly in the next release. |
# [2.3.0](v2.2.3...v2.3.0) (2024-11-09) ### Bug Fixes * **assetpath.cs:** retarget PATH_PROJECT ([45f5620](45f5620)), closes [#79](#79) * **builds:** node version now pulls from .nvmrc ([8564210](8564210)) * **conditions:** generic condition had exit and init reversed ([c9ac8cc](c9ac8cc)) * **dark mode:** boxes keep proper color in dark mode for the visualizer ([b3dd08f](b3dd08f)), closes [#48](#48) * **visualizer:** vertically connected nodes now connect properly ([321e47e](321e47e)), closes [#29](#29) ### Features * **visualizer:** pausing the game now keeps active node highlighting ([b031653](b031653)), closes [#94](#94)
🎉 This issue has been resolved in version 2.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
When I pause the editor, the behavior tree shows all the nodes as inactive.
This is unpractical because we want to ideally be able to pause and see exactly what our AI is doing at that particular frame.
(I am using Unity 2022.3.22f1)
I am surprised this issue hasn't been observed before, since when I look at the code it seems quite logical that there would be a bug there. I don't think it's Unity version related.
The state of activation of visual tasks is set to false inside of the OnGUI() method.
This works fine so long as the game is running. But the moment, the game is paused, the OnGUI() method is still running, which means all nodes become inactive.
The solution is to update the state of nodes in a method that runs at the same rate as the Update() function, in this case the EditorApplication.onUpdate. We can't do it in OnGUI because OnGUI() runs many times per frame and is completely unrelated to when the EditorApplication.isPaused is set properly.
=> This snippet is to show the first thing I tried and it doesn't work.
It's because EditorApplication.isPaused is not set to true before OnGUI has had the time to run several times already, so the nodes are set to false.
Anyway... here's the proper approach:
We print things in OnGUI. But we update values in EditorApplication.onUpdate... And we don't update values when the game is paused.
In BehaviorTreeWindow.cs
In BehaviorTreePrinter.cs
In VisualTask.cs
In NodePrinterController.cs
Now our GUI logic is separated from our value updating logic, and the nodes are keeping their active state even when the game is paused!
The text was updated successfully, but these errors were encountered: