Skip to main content

LensStudio:Serialization.IWriter

Class

Interface for writing serializable data.

Index

Example

// IWriter serializes data to a string. Obtain one via Yaml.createWriter()
// (the constructor is protected). The resulting writer can be passed to
// APIs that persist state — for example, Editor.Dock.IDockManager.write()
// dumps the current dock layout and panel identifiers into the writer.
const { Yaml } = await import('LensStudio:Serialization');

const writer = Yaml.createWriter();

// Serialize the current dock layout (panel IDs + attached/detached state)
// through the IDockManager interface. This writes scene object-style
// properties into the writer.
const dockManager = this.pluginSystem.findInterface(
Editor.Dock.IDockManager.interfaceId
) as unknown as Editor.Dock.IDockManager;

if (!Editor.isNull(dockManager)) {
dockManager.write(writer);
}

// getString() returns the YAML output — a structured, JSON-like string
// describing every panel and its dock state. It can be round-tripped
// through Yaml.createReader() and IDockManager.read() to restore layout.
const serialized = writer.getString();
console.log('IWriter produced', serialized.length, 'bytes of YAML');
console.log(serialized);

Extends

Methods

getString()

getString(): string

Get the serialized output as a string.

Returns

string


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame