Script Properties
Overview
Script properties let you configure behavior parameters from the Inspector without recompiling. Properties are stored as string key-value pairs on the NativeScript component and serialized with the scene.
Adding Properties in the Editor
- Select an entity with a NativeScript component
- Type a property name in the text field at the bottom of the component
- Click + Add
- Enter the value in the property field
- Press Enter to confirm
To remove a property, right-click on it.
Reading Properties in Code
Read properties in OnStart to initialize your behavior:
Type Conversion
Properties are stored as strings. Convert them in OnStart:
Include <cstdlib> for std::atof and std::atoi.
Serialization
Properties are saved to scene files automatically:
Helper Pattern
For behaviors with many properties, use a helper method: