0 votes

I know it's not a Java, but anyway, how I can the check enum type?

enum ETestType {

func check(enumType):
        if enumType is ETestType:
            print("is a my enum what i need!")

Or there is no way check it?

P.S> if it helps, I need that for only one function for ALL my enums stored in Singleton.
actually for calling the name of Enum by Singleton.getenumname(enumType)

func get_enum_name(enumType, idx):
    if enumType is EMyEnum:
        return EMyEnum.keys()[idx]

THank you guys!

in Engine by (38 points)

1 Answer

+1 vote
Best answer

As far as I know, enum in Godot is just syntactic sugar for dictionary type, so you can't use it as a type. According to document here: https://docs.godotengine.org/en/3.1/getting_started/scripting/gdscript/static_typing.html

You can’t use Enums as types:

Hope this also will help: https://godotengine.org/qa/37768/what-is-enum

by (138 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.