Skip to content

Instantly share code, notes, and snippets.

@sonnguyen9800
Created December 16, 2023 16:52
Show Gist options
  • Save sonnguyen9800/96dbed6876a8f17fa8066a6bdde94de9 to your computer and use it in GitHub Desktop.
Save sonnguyen9800/96dbed6876a8f17fa8066a6bdde94de9 to your computer and use it in GitHub Desktop.
[Godot] Parse String to Enum.gd
func ParseStringToEnum(enum_type: Dictionary, string_value: String) -> int:
var clone = enum_type.duplicate()
var keys = clone.keys()
var index = keys.find(string_value)
if index != -1:
return index
else:
print("String not found in enum.")
return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment