English 中文(简体)
Godot 4 upgrade: export array of flags
原标题:

I m upgrading a project from Godot 3 to Godot 4. In Godot 3 I had an export variable that was an array of bit flags. This essentially allowed me to set the number of a given item and set bit flags for each of the items.

Example:

export (Array, EnumOfFlags, FLAGS) var items:= [0, 1]: setget = _set_items

In upgrading to Godot 4, when I switch to the @export_flags syntax I m running into two problems.

  1. @export_flags won t accept an enum as an argument. I get this error when I try supplying EnumOfFlags as the only argument: Invalid argument for annotation "@export_flags": argument 1 should be "String" but is "EnumOfFlags". This is annoying since using an enum allows me to reuse and reference the flags really cleanly. I can work around this.
  2. @export_flags requires the variable to be an integer and doesn t like the concept of an array of bit flags. I get this error when I try to assign the array above as the default value: "@export_flags" annotation requires a variable of type "int" but type "Array" was given instead.. This is more problematic since I want different flags for each item. I can think of some possible workarounds but they involve writing significantly more code.

Are either of these still possible in Godot 4? The docs suggest there are more advanced exports but the advanced exports section seems to be incomplete (it gives some things you should be familiar with before reading more but then ends).

问题回答

暂无回答




相关问题
Upgrade to ASP.NET MVC version 2

I have been doing some work on a ASP.NET MVC project today i tried to publish the website but i ve got an error. my hosting service provider told me is due to the fact that i have version 1 while they ...

How do you upgrade MAMP s PHP to PHP 5.3 ?

I haven t been able to find any resources on how to do this.. Anyone have any ideas or resources?! I ve tried changing the ./configure options and I m solving things one at a time but it seems like ...

Delphi 2009 Upgrade Question

i bought yesterday an upgrade to Delphi 2009 Pro. Now i have the problem that i have a version of Delphi 5 Enterprise, but it s registered, but the account has been lost. Is there a way to get the ...

热门标签