cat := class<concrete>():
# field must be initialized because the class is concrete
Name : string = "Cat"
unique
Verse の unique クラスには各インスタンスの一意の ID が割り当てられています。 そのため、同じ unique クラスに 2 つのインスタンスがある場合、それらは同じフィールド値を持っていても別のインスタンスとして区別されます。 これにより、unique クラスのインスタンスは、その ID を比較するだけで等しいかどうかを判断できます。 unique 指定子がないクラスは、そのような ID がなく、等しいかどうかを判断するにはそのフィールドの値を比較する必要があります。 つまり、unique クラスは = および <> 演算子で比較でき、比較可能な型のサブタイプです。
Verse
unique_class := class<unique>:
Field : int
Main()<decides> : void =
X := unique_class{Field := 1}
X = X # X is equal to itself
Y := unique_class{Field := 1}
X <> Y # X and Y are unique and therefore not equal
final
final 指定子は、クラスとクラスのメンバーでのみ使用でき、次の制限があります。
クラスに final 指定子がある場合、そのクラスのサブクラスを作成することはできません。
フィールドに final 指定子がある場合、サブクラスのフィールドをオーバーライドすることはできません。
メソッドに final 指定子がある場合、サブクラスのメソッドをオーバーライドすることはできません。
component := class {}
my_final_class := class<final_super>(component) {}
# Not allowed since my_final_class has the final_super specifier.
my_subclass_type := class(my_final_class) {}
# Enums are <closed> by default so you must explicitly define the enum as an open enum with the <open> specifier
my_enum := enum<open>{Value1, Value2, Value3}
Closed
現在、列挙型にのみ適用できます。
列挙型はデフォルトでクローズドの状態です。
クローズドの列挙型は、曜日のように値が変わらないことが想定されるケースに最適です。
Verse
# Enums are <closed> by default so the specifier is not required.
my_enum := enum{Value1, Value2, Value3}
# You can also explicitly define the enum as closed by adding the <closed> specifier
my_enum := enum<closed>{Value1, Value2, Value3}
実装指定子
コードを記述するときに実装指定子を使用することはできません。ただし、実装指定子は UEFN API で確認できます。
# An editable string that displays as a text box in the editor.
# Editable text boxes currently do not support tooltips or categories.
@editable_text_box:
# Whether this text can span multiple lines.
MultiLine := true
# The maximum amount of characters this text block can display.
MaxLength := 32
MessageBox:string = "This is a short message!"
# An editable slider that uses the float type. You can drag the slider in the editor to increase
# or decrease the value.
@editable_slider(float):
# The categories this editable belongs to.
Categories := array{FloatsCategory}
# The tool tip for this editable.
ToolTip := SliderTip
# The minimum value of each component. You cannot set an editable value for this number lower
# An editable number with minimum and maximum
@editable_number(int):
# The tool tip for this editable.
ToolTip := EditableIntTip
# The category this editable belongs to.
Categories := array{IntsCategory}
# The minimum value of each component. You cannot set an editable value for this number lower
# An editable vector slider. You can drag to change the values of each of the vector components.
@editable_vector_slider(float):
# The tool tip for this editable.
ToolTip := VectorSliderTip
# The categories this editable belongs to.
Categories := array{FloatsCategory}
# Shows the option to preserve the ratio between vector values in the editor.
ShowPreserveRatio := true
# An editable vector number, which can be a vector2, vector2i, or vector3.
@editable_vector_number(float):
# The categories this editable belongs to.
Categories := array{FloatsCategory}
# The tool tip for this editable.
ToolTip := VectorFloatTip
# Shows the option to preserve the ratio between vector values in the editor.
An editable container of values. Currently, this only supports arrays.
@editable_container:
# The category this editable belongs to.
Categories := array{IntsCategory}
# The tool tip for this editable.
ToolTip := IntArrayTip
# Whether dragging elements to reorder this container is allowed.