Scripting API
Scripting API
FieldHint
Record in Abyss.Core, from Abyss.Core.
What a component's author said about one of its fields: how it is shown — [Range], [Tooltip] and [HideInInspector], on their way to an inspector — and what it was called before, [FormerlySerializedAs], on their way to a reload and a scene.
public record FieldHintRemarks
Kept on this side and never sent to the engine, which has no use for any of it: these say how a field is shown and what it was called, not where it is or what it holds. World keeps them with the component they were registered with, and an inspector asks for them by the component's id (World.HintsOf); a move from one build of a component to the next tells the engine the old names as it asks (World.MoveComponent). A Rust component's go the other way: they are on its type, and the engine says them (FieldHint.FromEngine).
A hint names a field or a part of one. The field table is flattened — Linear.X, Linear.Y — and a hint can be on either level: a tooltip on Linear is the row's, one on Linear.X is that box's, and hiding Linear hides both. That is the shape a struct inside a struct has in the source, and the shape Bevy's reflection gives a field of a field — each can carry attributes of its own, and bevy_reflect's own example of one is a slider's range (bevy_reflect 0.19.1, src/attributes.rs:11-35) — so a Rust component says the same things without a second rule, by the same names: #[reflect(@Range(0.0, 10.0))], @Tooltip("..."), @HideInInspector and @FormerlySerializedAs("...").
Write them with the attributes and let the generator behind AbyssComponentAttribute make the table. A table written by hand is checked when it is registered, as the field table is.
Constructors
FieldHint
public FieldHint(string Field)What a component's author said about one of its fields: how it is shown — [Range], [Tooltip] and [HideInInspector], on their way to an inspector — and what it was called before, [FormerlySerializedAs], on their way to a reload and a scene.
Parameters
Field: The field's name as the table names it, or the part before one of its dots.
Kept on this side and never sent to the engine, which has no use for any of it: these say how a field is shown and what it was called, not where it is or what it holds. World keeps them with the component they were registered with, and an inspector asks for them by the component's id (World.HintsOf); a move from one build of a component to the next tells the engine the old names as it asks (World.MoveComponent). A Rust component's go the other way: they are on its type, and the engine says them (FieldHint.FromEngine).
A hint names a field or a part of one. The field table is flattened — Linear.X, Linear.Y — and a hint can be on either level: a tooltip on Linear is the row's, one on Linear.X is that box's, and hiding Linear hides both. That is the shape a struct inside a struct has in the source, and the shape Bevy's reflection gives a field of a field — each can carry attributes of its own, and bevy_reflect's own example of one is a slider's range (bevy_reflect 0.19.1, src/attributes.rs:11-35) — so a Rust component says the same things without a second rule, by the same names: #[reflect(@Range(0.0, 10.0))], @Tooltip("..."), @HideInInspector and @FormerlySerializedAs("...").
Write them with the attributes and let the generator behind AbyssComponentAttribute make the table. A table written by hand is checked when it is registered, as the field table is.
Properties
Field
public string Field { get; init; }The field's name as the table names it, or the part before one of its dots.
Range
public FieldRange? Range { get; init; }The slider's ends, from RangeAttribute; for a number only.
Tooltip
public string? Tooltip { get; init; }What to say when the pointer rests on it, from TooltipAttribute.
Hidden
public bool Hidden { get; init; }Whether the normal view leaves it out, from HideInInspectorAttribute.
FormerNames
public IReadOnlyList<string> FormerNames { get; init; }What the field was called before, from FormerlySerializedAsAttribute: dotted names as the table would have named it then, so a field inside a struct reads Linear.Y, under the struct's name as it is now.
Color
public FieldColor? Color { get; init; }How the color it holds is shown, from a Rust field's @ColorUsage; null where it says nothing.
Asset
public FieldAsset Asset { get; init; }What kind of asset the field names, for a reference to one — a PrefabRef, or a Rust field of two numbers that says @AssetRef("audio") — shown as a slot a file is dropped on; FieldAsset.None for a field that is no reference.
Entity
public bool Entity { get; init; }Whether the field names an entity — an EntityRef, one whole number, 0 for none — shown as a slot an entity is dropped on, saved by the entity's scene id and given the entity back on a load.
Bus
public bool Bus { get; init; }Whether the field names a bus of the game's mix by its identity — a Rust field of one number that says @AudioBusRef, an Audio Source's Output — shown as a list of the buses by their names.
SortingLayer
public bool SortingLayer { get; init; }Whether the field names a sorting layer of the game's by its identity — a Rust field of one number that says @SortingLayerRef, a sprite's Sorting Layer — shown as a list of the layers by their names.
LayerMask
public bool LayerMask { get; init; }Whether the field is a mask of the project's layers, a bit each — a Rust field of one number that says @LayerMaskRef, a camera's Culling Mask — shown as a list of the layers by their names to tick, under Nothing and Everything.
LayerMatrix
public bool LayerMatrix { get; init; }Whether the field is a LayerMatrix, which layers meet which: its 32 values a row a layer, shown as a triangle of ticks by the layers' names.
Text
public bool Text { get; init; }Whether the field is a fixed text — a FixedText64 and the other sizes — its bytes the UTF-8 of what it holds and zeros after: shown as a box to type in, and written as its text.
Localized
public bool Localized { get; init; }Whether the field names a string of the game's — a LocalizedString, three whole numbers: its table's identity's halves and its entry's — shown as a slot the string is picked in, and written as its table, its entry and its name.
DataType
public string? DataType { get; init; }For a field naming a data asset — an AssetRef<T>, its FieldHint.Asset FieldAsset.Data — the full name of the kind it names, which its slot takes only files of; null for any other field.
FileKind
public string? FileKind { get; init; }For a field naming a file of a package's own kind — a FileRef, its FieldHint.Asset FieldAsset.File — the ending of the files its slot takes, its dot included, as FileKindAttribute says it; null for any file, and for any other field.
Choices
public IReadOnlyList<FieldChoice> Choices { get; init; }For a field that holds a C# enum, its values by name, in the order the enum declares them — shown as a list to pick from rather than as a number; empty for any other field. The field holds the enum's number, as the enum's underlying type is stored, and a scene writes that.
Flags
public bool Flags { get; init; }Whether the enum is [Flags]: its values are bits, any of them together, shown as a list of them to tick with Nothing and Everything above, rather than one to pick.
List
public int List { get; init; }For a field that is a fixed list — a FixedList8<T> and the sizes above — how many items it has room for; zero for any other. Its fields are Points.Count and each item, Points[0], or Points[0].X and Points[0].Y for an item that is a struct; the inspector shows them as one list with its size, and the items it holds.
Methods
CountOf
public static string CountOf(string list)The name of a fixed list's count field: Points.Count for the list list.
Parameters
list
ItemOf
public static string ItemOf(string list, int index)The name of a fixed list's item: Points[3] for the list list.
Parameters
listindex
Covers
public bool Covers(string name)Whether this hint is about name: the same field, or a part of it.
Parameters
name: A field's dotted name.
Renamed
public static string? Renamed(IReadOnlyList<FieldHint> hints, string name)What a field that had name is called now, by what the component's fields say they were called before — or null if none of them says it had that name.
Parameters
hints: The component's hints, as registered.name: A field's dotted name as it was.
Outermost first, so a struct renamed carries what is inside it and a field inside it renamed too is found under the struct's new name: Velocity.Y, with Velocity now Linear and Y now X, is Linear.Y and then Linear.X.
Only what the old names say. Whether the component still has a field by that name — which comes first — is the caller's to ask; see FormerlySerializedAsAttribute.
