Fudge Core
    Preparing search index...

    Function serialize

    • 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).

      Serialization: The automatic serialization occurs after an instance's Serializable.serialize / Serializable.deserialize method was called.

      • Primitives and enums will be serialized as is.
      • Serializables will be serialized nested.
      • 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 after EVENT.GRAPH_DESERIALIZED / EVENT.GRAPH_INSTANTIATED was broadcast through the hierarchy. Node references can only be serialized from a Component.

      Example:

      import ƒ = FudgeCore;

      @ƒ.serialize
      export class MyScript extends ƒ.ComponentScript {
      #size: number = 1;

      @ƒ.serialize(String) // display a string in the editor
      public info: string;

      @ƒ.serialize(ƒ.Vector3) // display a vector in the editor
      public position: ƒ.Vector3 = new ƒ.Vector3(1, 2, 3);

      @ƒ.serialize(ƒ.Material) // drop a material inside the editor to reference it
      public resource: ƒ.Material;

      @ƒ.serialize(ƒ.Node) // drop a node inside the editor to reference it
      public reference: ƒ.Node

      @ƒ.serialize(Number) // display a number in the editor
      public get size(): number {
      return this.#size;
      }

      // define a setter to allow writing to size, or omit it to leave the property read-only
      public set size(_size: number) {
      this.#size = _size;
      }
      }

      Side effects:

      Parameters

      • _value: new (...args: any[]) => Serializable
      • _context: ClassDecoratorContext

      Returns void

      Jonas Plotzky, HFU, 2024-2025

    • 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).

      Serialization: The automatic serialization occurs after an instance's Serializable.serialize / Serializable.deserialize method was called.

      • Primitives and enums will be serialized as is.
      • Serializables will be serialized nested.
      • 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 after EVENT.GRAPH_DESERIALIZED / EVENT.GRAPH_INSTANTIATED was broadcast through the hierarchy. Node references can only be serialized from a Component.

      Example:

      import ƒ = FudgeCore;

      @ƒ.serialize
      export class MyScript extends ƒ.ComponentScript {
      #size: number = 1;

      @ƒ.serialize(String) // display a string in the editor
      public info: string;

      @ƒ.serialize(ƒ.Vector3) // display a vector in the editor
      public position: ƒ.Vector3 = new ƒ.Vector3(1, 2, 3);

      @ƒ.serialize(ƒ.Material) // drop a material inside the editor to reference it
      public resource: ƒ.Material;

      @ƒ.serialize(ƒ.Node) // drop a node inside the editor to reference it
      public reference: ƒ.Node

      @ƒ.serialize(Number) // display a number in the editor
      public get size(): number {
      return this.#size;
      }

      // define a setter to allow writing to size, or omit it to leave the property read-only
      public set size(_size: number) {
      this.#size = _size;
      }
      }

      Side effects:

      Type Parameters

      • T
      • C extends new (...args: any[]) => T

      Parameters

      • _constructor: C

      Returns (
          _value: unknown,
          _context: ClassPropertyContext<
              T extends Node
                  ? Node extends T<T> ? Component : Serializable
                  : Serializable,
              T,
          >,
      ) => void

      Jonas Plotzky, HFU, 2024-2025

    • 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).

      Serialization: The automatic serialization occurs after an instance's Serializable.serialize / Serializable.deserialize method was called.

      • Primitives and enums will be serialized as is.
      • Serializables will be serialized nested.
      • 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 after EVENT.GRAPH_DESERIALIZED / EVENT.GRAPH_INSTANTIATED was broadcast through the hierarchy. Node references can only be serialized from a Component.

      Example:

      import ƒ = FudgeCore;

      @ƒ.serialize
      export class MyScript extends ƒ.ComponentScript {
      #size: number = 1;

      @ƒ.serialize(String) // display a string in the editor
      public info: string;

      @ƒ.serialize(ƒ.Vector3) // display a vector in the editor
      public position: ƒ.Vector3 = new ƒ.Vector3(1, 2, 3);

      @ƒ.serialize(ƒ.Material) // drop a material inside the editor to reference it
      public resource: ƒ.Material;

      @ƒ.serialize(ƒ.Node) // drop a node inside the editor to reference it
      public reference: ƒ.Node

      @ƒ.serialize(Number) // display a number in the editor
      public get size(): number {
      return this.#size;
      }

      // define a setter to allow writing to size, or omit it to leave the property read-only
      public set size(_size: number) {
      this.#size = _size;
      }
      }

      Side effects:

      Type Parameters

      • T extends String | Number | Boolean

      Parameters

      • _constructor: new (...args: any[]) => T

      Returns (_value: unknown, _context: ClassPropertyContext<Serializable, T>) => void

      Jonas Plotzky, HFU, 2024-2025

    • 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).

      Serialization: The automatic serialization occurs after an instance's Serializable.serialize / Serializable.deserialize method was called.

      • Primitives and enums will be serialized as is.
      • Serializables will be serialized nested.
      • 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 after EVENT.GRAPH_DESERIALIZED / EVENT.GRAPH_INSTANTIATED was broadcast through the hierarchy. Node references can only be serialized from a Component.

      Example:

      import ƒ = FudgeCore;

      @ƒ.serialize
      export class MyScript extends ƒ.ComponentScript {
      #size: number = 1;

      @ƒ.serialize(String) // display a string in the editor
      public info: string;

      @ƒ.serialize(ƒ.Vector3) // display a vector in the editor
      public position: ƒ.Vector3 = new ƒ.Vector3(1, 2, 3);

      @ƒ.serialize(ƒ.Material) // drop a material inside the editor to reference it
      public resource: ƒ.Material;

      @ƒ.serialize(ƒ.Node) // drop a node inside the editor to reference it
      public reference: ƒ.Node

      @ƒ.serialize(Number) // display a number in the editor
      public get size(): number {
      return this.#size;
      }

      // define a setter to allow writing to size, or omit it to leave the property read-only
      public set size(_size: number) {
      this.#size = _size;
      }
      }

      Side effects:

      Type Parameters

      • T
      • E extends Record<keyof E, T>

      Parameters

      • _enum: E

      Returns (_value: unknown, _context: ClassPropertyContext<Serializable, T>) => void

      Jonas Plotzky, HFU, 2024-2025