OnLengthChanged_ Function Callback
On length changed function binding lets you know when an element added or removed from an array. This function pattern is only available for arrays.
Rules of Using OnLengthChanged_
- The array must be declared as public(instance editable) on blueprints.
- The function name must follow this format OnLengthChanged_ArrayName
- Underscore character after OnLengthChanged is required.
Implementation
- Click on ADD NEW and then BLUEPRINT CLASS on the Content Browser
- Pick Actor as parent class.
- Rename the actor name as “SimpleActor”.
- Click on the ADD COMPONENET under the Components tab. Search for the “ZDActor” and select the ZD ACTOR
- Click ADD NEW then VARIABLE under My Blueprints tab.
- Click on variable that you created, the Details panel will be shown in right side. Make it Array clicking pink bar on right-side of drop-down menu. Check Instance Editable.
- Click ADD NEW → FUNCTION on My Blueprint tab.
- Rename function name as OnLengthChanged_StringArray.
info
OnLengthChanged_ function pattern must required.
- Double click on OnLengthChanged_StringArray. Connect the node as shown in below. We set random integer between 0 and 42 to array element when array length changed(added a new element or deleted an element).
- Click actor that you created. Therefore on click Add Item. When we added or removed an element on string array, array value automatically set on blueprints.