# DataObject

## Runtime Methods

### CloneToRuntimeContainer

Clone this DataObject directly to its related runtime-DataLibrary

* \_ownerGameObject: An initial data object can have multiple runtime clones. When passing the owner game object, the runtime clone can be linked to this owner game object which makes it possible to retrieve the runtime clone by the owner game object.

### OnStart

Called on start after DataLibrary has been initialized

### OnEnd

Called after DataLibrary has been disabled

### GetSerializedData

Override this method to return the serialized data object class of your custom DataObject to make sure the data gets serialized as json when saving to a file.

### SetSerializedData

Gets called after the DataLibrary has loaded the json file. The \_data object contains the serialized data object.

### GetRuntimeDataObject

Return the runtime DataObject

* \_ownerGameObject: Provides the owner game object if the runtime DataObject has been cloned manually at runtime, otherwise the first in the list will be returned (which is usually the runtime clone which has been cloned automatically if data type has been set to be added to the runtime library in the editor).

### GetAllRuntimeDataObjectsFromThisType

Return all runtime DataObjects of the same type as this DataObject

### GetAllRuntimeDataObjectsFromThis

Return all runtime DataObjects which have been cloned from this DataObject

### GetInitialDataObject

Return the initial data object

### SetNewGuid

Set a new guid. Only for runtime data objects. This can be useful when creating new instances from GetAllRuntimeDataObjects, as newly created game objects will have a different guid.

## Editor Methods

### CustomGUI

Create custom GUI for this DataObject using UIElements

### Reset

Editor method. Resets the DataObject. Must be overridden in order to reset all custom values.

### Selected

Editor method which gets called when DataObject gets selected in the Databrain editor

### OnDelete

Editor method which gets called when a DataObject gets deleted in the Databrain editor

### IsValid

Editor method where you can return true or false if this DataObject is valid. If it returns as false, an exclamation mark is shown in the Databrain object list view.

### ConvertFromCSV

Override this method to manually convert CSV string data to your custom DataObject


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://giantgrey.gitbook.io/databrain/api/dataobject.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
