Scripting API

Scripting API

FormerlySerializedAsAttribute

Class in Abyss.Core, from Abyss.Core.

Says what a field was called before, so what was kept under that name is found again: a field is renamed without losing its saved value.

public sealed class FormerlySerializedAsAttribute : Attribute

Remarks

Where it is read: when a game's scripts are built again with the editor open, a value is moved from the old field to the renamed one rather than dropped; and when a scene or a prefab written before the rename is opened, the value the file keeps under the old name goes into the field that has it now. A scene saved afterwards writes the new name, so the attribute can go once every file that names the old one has been saved again.

A name that is still there comes first. A field the component still has by its own name keeps its own value; only a name the component no longer has is looked for among what its fields were called before. So a field given back the old name later is its own field, and a file saved after the rename is read the same however often it is opened.

More than one, for a field renamed more than once. On a field holding a struct, it renames everything inside it: Velocity.X is found as Linear.X. The name is the field's own, not a path: on a field inside a struct it is that field's old name there.

On a component's struct, it is what the component was called. A scene names a component by what it is called, so the old name has to be said. It is read in the same two places: a rebuild moves the values of the component by the old name onto this one, and a scene or a prefab naming the old one reads it into this one — only once nothing is called that now, and only where no other component says it had the name too. The name is the component's as a scene held it: its type's name, or the AbyssComponentAttribute.Name it had.

[AbyssComponent][FormerlySerializedAs("Hitpoints")]public partial struct Health{    [FormerlySerializedAs("Hp")]    public int Current;}

Constructors

FormerlySerializedAsAttribute

public FormerlySerializedAsAttribute(string oldName)

Says what a field was called before, so what was kept under that name is found again: a field is renamed without losing its saved value.

Parameters

  • oldName: The name of the field, or of the component, before the rename.

Where it is read: when a game's scripts are built again with the editor open, a value is moved from the old field to the renamed one rather than dropped; and when a scene or a prefab written before the rename is opened, the value the file keeps under the old name goes into the field that has it now. A scene saved afterwards writes the new name, so the attribute can go once every file that names the old one has been saved again.

A name that is still there comes first. A field the component still has by its own name keeps its own value; only a name the component no longer has is looked for among what its fields were called before. So a field given back the old name later is its own field, and a file saved after the rename is read the same however often it is opened.

More than one, for a field renamed more than once. On a field holding a struct, it renames everything inside it: Velocity.X is found as Linear.X. The name is the field's own, not a path: on a field inside a struct it is that field's old name there.

On a component's struct, it is what the component was called. A scene names a component by what it is called, so the old name has to be said. It is read in the same two places: a rebuild moves the values of the component by the old name onto this one, and a scene or a prefab naming the old one reads it into this one — only once nothing is called that now, and only where no other component says it had the name too. The name is the component's as a scene held it: its type's name, or the AbyssComponentAttribute.Name it had.

[AbyssComponent][FormerlySerializedAs("Hitpoints")]public partial struct Health{    [FormerlySerializedAs("Hp")]    public int Current;}

Properties

OldName

public string OldName { get; }

The name of the field, or of the component, before the rename.