Skip to content

Implement a StateBase interface? #12

Description

@Invertex

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.

Activity

  1. Inspiaaa commented on May 18, 2024

    @Inspiaaa
    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.

  2. Invertex commented on May 18, 2024

    @Invertex
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions