CREATE YOUR WORLD
Scripting

ScriptableObject

5min

ZepetoScriptableObject supports Unity ScriptableObject. ZepetoScriptableObject is a data container that saves large amounts of data, such as world data settings and character options.

To create a new ZepetoScriptableObject file, click the [+] icon in the top left corner of the Project panel, or click Assets → Create → ZEPETO → ScriptableObject.

Document image




The newly created ZepetoScriptableObject needs to be connected by creating scripts with a defined data class.

Document image


Make a new ZEPETOScript file, and declare the data you will use as the member variables.

Here are some sample codes that can be used as data.

TypeScript




When you link the ZEPETOScript with the defined data class to ZepetoScriptableObjects, you will see those data in the Inspector window, as shown below.

Document image




Create a ZEPETOScript file to call data from the ZepetoScriptableObject.

Import the ZepetoScriptableObject from the ZEPETOScript and import the data type you have declared as well.

TypeScript




Document image




Declare the ZepetoScriptableObject’s as properties in the ZEPETOScript.

TypeScript




Open the Inspector window in ZEPETOScript assign values for the ZepetoScriptableObject properties, as shown below.

Document image




This sample shows how you can use the ZepetoScriptableObject and access it’s values.

TypeScript




To access a primitive type of member variable, declare it as a generic type or covert it using type casting, like the example shown below.

TypeScript




Check the full code example for ScriptableObject.

TypeScript




Updated 10 Oct 2024
Doc contributor
Did this page help you?