# Databrain - FAQ

## DataObjectDropdown Attribute

<details>

<summary>Can I add a DataObjectDropdown attribute inside a DataObject class to reference other DataObjects inside of the Databrain editor? </summary>

Yes absolutely. Simply add the \[DataObjectDropdown] attribute without any additional parameter. The library will be found automatically.

</details>

<details>

<summary>Can I use a return method instead of a name as the DataLibrary parameter in the DataObjectDropdown attribute?</summary>

Yes, you can! This is a great way when you have a singleton class which holds the DataLibrary in your scene. Here's an example code:

```csharp
// Simply add the name of the DataLibrary returning method
[DataObjectDropdown(nameof(GetLibrary))]
public MyDataObject myDataObject;

public DataLibrary GetLibrary()
{
    return DataManager.Instance.data;
}
```

This would require a singleton of type DataManager which looks like this:\
Please note that you should also add the OnValidate method so that the DataLibrary will be found in the editor (not only at runtime).

```csharp
// SINGLETON Example
// Please make sure to add the OnValidate method like in this example
// to your singleton class.
public class DataManager : MonoBehaviour
{
    public static DataManager Instance { get; private set; }

    public DataLibrary data;
    
    
    private void OnValidate()
    {
        Instance = this;
    }

    public void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this);
            return;
        }

        Instance = this;
    }
}
```

</details>

<details>

<summary>Does the DataObjectDropdown support sub-types?</summary>

Yes, simply set the includeSubtypes parameter to true:

```csharp
[DataObjectDropdown(includeSubtypes: true)]
public MyDataObject dataObject;
```

</details>

<details>

<summary>My DataObjectDropdown doesn't show up. All I see is a No GUI Implemented label.</summary>

This mostly happens because of another third-party asset installed. Please check out following page for a possible fix.

[No GUI Implemented - FIX](/databrain/dataobject-property-drawer/no-gui-implemented-fix.md)

</details>

## General

<details>

<summary>My properties (get; set;) won't show up in the DatabrainEditor </summary>

The reason for this is that when you declare a property like public int Speed {get; set;} a hidden backing field is generated by the compiler which is where the value is actually stored, this field is private and so will not be serialized automatically by Unity's serializer. C# 7.3 added Auto-implemented property field-targeted attributes, allowing you to do this:

```
[field:SerializeField] public int Speed {get; set;}
```

This will apply the SerializeField attribute to the hidden generated field and Unity should serialize it normally.

</details>

<details>

<summary>How can I enable Odin Inspector attribute support inside of the Databrain editor?</summary>

Simply use the \[UseOdinInspector] attribute to your DataObject class.

</details>


---

# 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/faq/databrain-faq.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.
