User Tools

Site Tools


DzSimpleElementScriptData

DzCustomData implementation that can be associated with an individual DzElement instance.

More...

Inherits :

Constructors

DAZ Script
DzSimpleElementScriptData ( String name, Boolean persistent=true )

Methods

DAZ Script
StringgetScriptFilePath ()
voidsetScriptFilePath ( String script )

Detailed Description

Implements a custom data item that causes a specified script to be executed after the element that owns the data item has been loaded into the scene.

A global transient variable named DataItem, which refers to the DzSimpleElementScriptData that invoked the execution of the script, is provided to the script in the global context at runtime. Attempts to use this global variable outside of the associated script will result in a ReferenceError.

A global transient variable named FileIOSettings, which refers to the DzFileIOSettings that was used when the element that owns the data item was loaded, is provided to the script in the global context at runtime. Attempts to use this global variable outside of the associated script will result in a ReferenceError. (since 4.9.4.109)

If the DzSettings for this data item contains a boolean setting named RunOnce set to true, the specified script will be run once and then the data item will be deleted from the element.

Attention:

  • The differences between this implementation and DzElementPostLoadFileData are that this implementation must reference the file path of a script and has an associated DzSettings that can be used to configure the script.

Constructors


DzSimpleElementScriptData( String name, Boolean persistent=true )

Default constructor.

Parameter(s):

  • name - The name for the data item. This must be unique for all data items on a given element - i.e. an element can not have two data items with the same name.
  • persistent - If true, the data item will be saved with the element to the native file format.

Methods


String : getScriptFilePath()

Return Value:

  • The file path of the script for this data item (if any), otherwise an empty string.

void : setScriptFilePath( String script )

Sets the file path of the script for this data item.

Parameter(s):

  • script - The file path of the script.