Decorator to mark properties of a Serializable for automatic serialization and editor configuration.
Editor Configuration:
Specify a type (constructor) for an attribute within a class's metadata.
This allows the intended type of an attribute to be known by the editor (at runtime), making it:
A valid drop target (e.g., for objects like Node, Texture, Mesh).
Display the appropriate input element, even if the attribute has not been set (undefined).
SerializableResources will be serialized via their resource id and fetched with it from the project when deserialized.
Nodes will be serialized as a path connecting them through the hierarchy, if found. During deserialization, the path will be unwound to find the instance in the current hierarchy. They will be available afterEVENT.GRAPH_DESERIALIZED / EVENT.GRAPH_INSTANTIATED was broadcast through the hierarchy. Node references can only be serialized from a Component.
Example:
importƒ = FudgeCore;
@ƒ.serialize exportclassMyScriptextendsƒ.ComponentScript { #size: number = 1;
@ƒ.serialize(String) // display a string in the editor publicinfo: string;
@ƒ.serialize(ƒ.Vector3) // display a vector in the editor publicposition: ƒ.Vector3 = newƒ.Vector3(1, 2, 3);
@ƒ.serialize(ƒ.Material) // drop a material inside the editor to reference it publicresource: ƒ.Material;
@ƒ.serialize(ƒ.Node) // drop a node inside the editor to reference it publicreference: ƒ.Node
@ƒ.serialize(Number) // display a number in the editor publicgetsize(): number { returnthis.#size; }
// define a setter to allow writing to size, or omit it to leave the property read-only publicsetsize(_size: number) { this.#size = _size; } }
Side effects:
Attributes with a specified type will always be included in the base-mutator
(via Mutable.getMutator), regardless of their own type. Non-mutable objects
will be displayed via their toString method in the editor.
Decorator to mark properties of a Serializable for automatic serialization and editor configuration.
Editor Configuration: Specify a type (constructor) for an attribute within a class's metadata. This allows the intended type of an attribute to be known by the editor (at runtime), making it:
undefined
).Serialization: The automatic serialization occurs after an instance's Serializable.serialize / Serializable.deserialize method was called.
Example:
Side effects: