Skip to content
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

Implement a StateBase interface? #12

Open
Invertex opened this issue Jun 13, 2022 · 2 comments
Open

Implement a StateBase interface? #12

Invertex opened this issue Jun 13, 2022 · 2 comments

Comments

@Invertex
Copy link
Contributor

Is there a reason for not implementing StateBase as an interface so states can be used as protected types such as MonoBehaviour and ScriptableObject? It seems like the only concrete part of the class is the exitTime constructor, but that seems like something that doesn't need to be. Implementing classes can simply choose to provide constructors that override that internal value or not and the interface can have a property for it.

@Inspiaaa
Copy link
Owner

Hi @Invertex,
Thanks for the feature request! Using interfaces for states and transitions instead of common base classes generally seems like a good idea. I will consider it for future versions of UnityHFSM.

Such a change would entail significant refactoring and changes to documentation. Furthermore, the possible negative impact on performance should be carefully investigated.

Currently, it is already possible to show custom state classes in the inspector by marking them as Serializable. In the upcoming 2.1 release, the serialization error due to Time.time will be fixed, meaning that this will become a viable option.

@Invertex
Copy link
Contributor Author

Great to hear you might consider it, hope it works out!

And that's great to hear about the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants