You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When exporting named enums in 3.5.x you could define them outside of the export declaration and then export them with flags. The enum could be defined within the file you were working on, or in an autoload file.
extends Resource
class_name DefinedColor
export (Types.ColorTypes, FLAGS) var colorType
export (Types.ColorValue) var colorValue
export (String) var name
export (Color) var vColor
tldr for character generation I want to create predefined colors, and then flag them with what category they fall in, and whether the naturally occur as a hair or skin color. I'd also want to do this for other named enums as well.
And this works well in 3.5.x- when defining a export var using a named enum there are checkboxes available I can use to set the var up in editor where in a node or custom resource. However in 4.0 beta that no longer seems to be the case
As shown in the documents, we can do this for enums if we define them during the export @export_flags("Fire", "Water", "Earth", "Wind") var spell_elements = 0
We should have the same functionality for Named Enums in 4.x
My attempt at implementing in Godot 4.0 beta 11 in my project, to be clear not messing with the editor's code, just playing around to see if the functionality is there:
class_name DefinedColor
#The following two ways I tried don't work and I wasn't able to find how to do it in the documentation so I believe this is missing functionality
@export_flags(Types.ColorTypes) var colorType
@export(Types.ColorTypes, FLAGS) var colorType2
@export var colorValue: Types.ColorValue
@export var name: String@export var vColor: Color
Steps to reproduce
Create a new Godot project
Create a new script extending resource or node
Create a named enum with multiple options
Attempt to create an exported variable using the previously created named enum with flags
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered:
Is there a workaround for this until it's added? I used to rely on this in Godot 3.x. I guess our best bet for now is probably just hardcoding 😷 the bit flags 🤢 for now 🤮.
EDIT. Since there is no similar annotation for using enum on a non-enum-typed variable, I'm now not sure if a similar annotation for flags is a good idea.
Or we can have an annotation for the enum declaration itself to make it auto-assign values using power of 2 instead of linearly? Because that would make those enums useful for scripting in general, not just in the export notation.
Either way, this is a proposal material, so it should be argued as a feature proposal.
Godot version
Godot 4.0 beta 11 x64 Windows
System information
Windows 11
Issue description
When exporting named enums in 3.5.x you could define them outside of the export declaration and then export them with flags. The enum could be defined within the file you were working on, or in an autoload file.
For example, this works in 3.5
Enum defined in an autoload file named Types:
enum ColorTypes{
HUMANSKIN,
HUMANHAIR,
RED,
BLUE,
YELLOW,
GREEN,
VIOLET,
ORANGE,
REDORANGE,
YELLOWORANGE,
YELLOWGREEN,
BLUEGREEN,
BLUEVIOLET,
REDVIOLET,
BROWN,
GREY,
BLACK,
WHITE}
tldr for character generation I want to create predefined colors, and then flag them with what category they fall in, and whether the naturally occur as a hair or skin color. I'd also want to do this for other named enums as well.
And this works well in 3.5.x- when defining a export var using a named enum there are checkboxes available I can use to set the var up in editor where in a node or custom resource. However in 4.0 beta that no longer seems to be the case
As shown in the documents, we can do this for enums if we define them during the export
@export_flags("Fire", "Water", "Earth", "Wind") var spell_elements = 0
We should have the same functionality for Named Enums in 4.x
My attempt at implementing in Godot 4.0 beta 11 in my project, to be clear not messing with the editor's code, just playing around to see if the functionality is there:
Steps to reproduce
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: