UnityHFSM icon indicating copy to clipboard operation
UnityHFSM copied to clipboard

Implement a StateBase interface?

Open Invertex opened this issue 3 years ago • 2 comments

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.

Invertex avatar Jun 13 '22 03:06 Invertex

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.

Inspiaaa avatar May 18 '24 18:05 Inspiaaa

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

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

Invertex avatar May 18 '24 18:05 Invertex