UnityHFSM icon indicating copy to clipboard operation
UnityHFSM copied to clipboard

feature request: OnActiveStateChanged event?

Open santutu opened this issue 2 years ago • 1 comments

I suggest to add an Active StateChanged event to StateMachine class to track the state. I took a quick look at the code, and I think it would be possible by invoking the event at StateMachine's ChangeState method. if this function is ok, I am willing to do pull request.

simple example fsm.OnActiveStateChanged += (activeState)=> Debug.Log(activeState);

santutu avatar May 14 '23 14:05 santutu

This event sounds pretty useful.

On Sun, May 14, 2023, 7:11 AM santutu @.***> wrote:

I suggest to add an Active StateChanged event to StateMachine class to track the state. I took a quick look at the code, and I think it would be possible by invoking the event at StateMachine's ChangeState method. if this function is ok, I am willing to do pull request.

simple example fsm.OnActiveStateChanged += (activeState)=> Debug.Log(activeState);

— Reply to this email directly, view it on GitHub https://github.com/Inspiaaa/UnityHFSM/issues/22, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKNKVBNQHX53I5EOOQE3JZTXGDRXHANCNFSM6AAAAAAYBF6IAQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Monsoonexe avatar May 14 '23 17:05 Monsoonexe

Hi @santutu, Thanks for the feature request and the implementation of it in your pull request! I especially appreciate that you added unit tests. Thanks a lot!

I have merged your PR and made a few small changes. It will be released with the upcoming 2.1 version.

As I have not encountered a real-world use case for this feature myself, I'll be rolling out this feature conservatively, starting with a minimal version and seeing how well it fares. Future versions may then include enhancements, once I know more about how this feature is used.

Inspiaaa avatar May 18 '24 18:05 Inspiaaa

+1, this feature would also be useful for my project

woodward54 avatar May 26 '24 18:05 woodward54

The "state changed" event is now available in the latest release (2.1) :+1:

Inspiaaa avatar May 29 '24 09:05 Inspiaaa

Thank you! @Inspiaaa

woodward54 avatar Jul 01 '24 01:07 woodward54