> For the complete documentation index, see [llms.txt](https://giantgrey.gitbook.io/databrain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giantgrey.gitbook.io/databrain/add-ons/logic/scene-components.md).

# Scene Components

Using Logic, you can reference scene-specific components or game objects.

## Define components

1. Go to the Components type in the Databrain editor and create a new data object.

<div align="left"><figure><img src="/files/bKlCzY08JQExHrxqeD8M" alt=""><figcaption></figcaption></figure></div>

2. Select the newly created data object. You can now define the component type by clicking on the dropdown button.

<div align="left"><figure><img src="/files/R0ZEUGN2RbDs65NQmy9V" alt=""><figcaption></figcaption></figure></div>

3. Now, when assigning a graph to a logic controller component in the scene, the inspector shows you all available scene components. You can assign the references here.

<div align="left"><figure><img src="/files/pq7TPF9I8NyEGy8tejfi" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
You can organize your components by simply creating a new class file and deriving from  SceneComponent. Like in following example:
{% endhint %}

```csharp
public class PlayerComponents : SceneComponent {}
```

<div align="left"><figure><img src="/files/rLx6D1KZ4BQtqCfl12B5" alt=""><figcaption></figcaption></figure></div>

## Access component in nodes

To access a component in your custom node, simply create a reference of type SceneComponent like this:

```csharp
public SceneComponent playerObject;
```

You can use the DataObjectDropdown attribute to specify the scene component type:

```csharp
[DataObjectDropdown(true, sceneComponentType: typeof(GameObject))]
public SceneComponent playerObject;
```

In your node execute method you can then access the assigned component using <mark style="background-color:orange;">GetReference\<T>(NodeData node)</mark>

```csharp
// adding true to include all derived types of SceneComponent
[DataObjectDropdown(true, sceneComponentType: typeof(GameObject))]
public SceneComponent playerObject;

public override void ExecuteNode()
{
    var _playerObject = playerObject.GetReference<GameObject>(this);
}   
```
