Skip to main content

Text

The Text asset type in OasisW is used to store general text data. It's versatile and can be used for various purposes such as storing dialogue, configuration data, or other text information.

Accessing Text Data in Scripts

To access data from a text asset in a script:

  1. Add the text asset as an attribute to your script.
  2. Access the resource of the text asset, which is the parsed string from the text file.

Example:

var TextScript = pc.createScript('textScript');

// Define a script attribute to hold the text asset
TextScript.attributes.add('textAsset', { type: 'asset', assetType: 'text' });

TextScript.prototype.initialize = function() {
if (this.textAsset) {
// Get the Text asset's resource (a string)
const textData = this.textAsset.resource;

// Output the content of the text asset
console.log('Content of text asset: ', textData);
}
};