Plush

Properties#

plupy · Type index

Module: plupy · obtained from block.props

A datablock's registered properties as a mapping (block.props): read props[key], write props[key] = value, inspect with schema().

block.props[key]          # read a registered property
block.props[key] = value  # write it
block.props.schema()     # tuple of property descriptors

Use exact registered keys, including punctuation/case. schema() supplies key, name (display label), kind, target_type and value descriptors. value includes the inherited/default fallback. Ordinary fields also supply min, max and whole; shader/material parameters add parameter_kind (Texture2D is a reference to image data, while its field kind remains Reference). Custom data also describes Record fields through fields (child descriptors with default), and List fields through element (the item descriptor). Enum descriptors include options. References are datablock handles, including inside records/lists; vectors and lists read as tuples. Custom records read as dictionaries. Nested values are snapshots: edit a copy and assign the complete property back, such as steps = list(block.props["Steps"]); steps.append({"Amount": 3}); block.props["Steps"] = steps. Missing record fields receive declared defaults; an unknown field or incompatible value is rejected with its property path. Use replace(values) for an explicit whole-definition schema update. Iteration yields keys. Missing reads raise KeyError; rejected writes raise PlupyError. A string that can only mean one value is accepted for its field: "0.3" for a number and "true"/"false" for a boolean are stored as 0.3 and True. Text fields are never converted, and any other string for a number raises PlupyError naming what was expected. Some fields require their component to exist before writing. The schema covers registered fields, not every possible asset field or gameplay state.

Assignments change shared authored data for all users. A wire may mask the visible result without preventing the source edit. Read the result through use.evaluated.

class Properties(Mapping)

A read-only mapping protocol (x[key], for key in x, len(x), key in x, .get, .keys(), .items()); writes are listed below when supported.

Usage and examples

Members: schema · Iteration · Length · Indexing · Assignment · replace

schema#

schema()

Property descriptors: key, name, kind, target_type, and value (with fallback). Custom records add fields (child descriptors with default); lists add element; enums add options. An incompatible stored property also includes error; its raw value remains readable for explicit repair. Enum options are declared C# names; use these exact names when assigning values, even when the Inspector displays spaced labels.

Iteration#

for item in x

The registered keys.

Length#

len(x)

How many registered properties there are.

Indexing#

x[key]

The value of a registered key (KeyError for an unknown one); references come back as handles, vectors as tuples.

Assignment#

x[key] = value

Write a registered key through an undoable edit; a rejected value raises PlupyError. Every user of the datablock sees the change.

replace#

replace(values: dict)

Replace all values of a compiled custom datablock, preserving its ID and name; one undoable edit.

Use exact C# property names. Records are dictionaries, lists are lists/tuples, and references are datablock handles or None. Omitted fields receive declared defaults. This explicitly removes old fields after a schema change; incompatible values fail without writing anything. Applies only to DataBlock declarations (data:Namespace.ClassName), not built-in datablocks or script components. data.name is not part of this dictionary; rename through block.name.

settings.props.replace({"Power": 18, "Steps": [{"Amount": 3}]})

DataBlock · PlupyError · Property · Use · edit

Source#