Get/Set runtime data
Due to the way scriptable objects work, you can only modify runtime-DataObjects at runtime. Runtime changes to an initial scriptable object (non-runtime object) won't persist.
Get/Set runtime DataObject from initial DataObject
If your DataObject has been added to the runtime DataLibrary as described in (Add data objects at runtime) then you can access the runtime DataObject from the initial DataObject (which was created in the editor) using GetRuntimeDataObject. See the following code:
Get/Set dynamic runtime DataObjects
The method CloneDataObjectToRuntime returns the newly created runtime data object. It is advised that you keep a reference of this dynamically added runtime data object to be able to modify its values.
Keep in mind, an initial DataObject can have multiple runtime clones. If you create multiple runtime clones at runtime, make sure to pass the owner game object to the CloneDataObjectAtRuntime method. This allows Databrain to later find the runtime clone associated to the owner game object.
Demo
Please also have a look at the demo scene in the Databrain package which demonstrates how to dynamically create DataObjects, change their values and restore the objects at runtime.
Last updated