> For the complete documentation index, see [llms.txt](https://ashobot.gitbook.io/ultimate-attributes-pack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ashobot.gitbook.io/ultimate-attributes-pack/component-getters.md).

# Component getters

<details>

<summary>GetComponentInObject</summary>

Takes automatically the target component in the object.

**Supported property types**

* Object Reference
* Exposed Reference
* Managed Reference

**Parameters**

* CreateOneIfEmpty

#### Limitations

Can't be used on arrays and lists.

<mark style="color:purple;">Code Example</mark>

```csharp
using UltimateAttributesPack;

public class GetComponentInObjectExample : MonoBehaviour
    {
        // GetComponentInObject attribute can be used to automatically get the target component of the object and set the variable with it
        [GetComponentInObject]
        public BoxCollider boxColliderOfObject;

        // You can set the param to true to create a new component in the object automatically if there is none
        // --> [GetComponentInObject(true)]
    }
```

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FsDpS7v4vUmeDjDlEo0b2%2FGetComponentInObject.PNG?alt=media&amp;token=4ef7712f-4872-4645-b640-cc906334fbfb" alt="" data-size="original">

</details>

<details>

<summary>GetComponentInParent</summary>

Takes automatically the target component in the object's parent.

**Supported property types**

* Object Reference
* Exposed Reference
* Managed Reference

**Parameters**

* CreateOneIfEmpty

#### Limitations

Can't be used on arrays and lists.

<mark style="color:purple;">Code Example</mark>

<pre class="language-csharp"><code class="lang-csharp">using UltimateAttributesPack;
<strong>
</strong><strong>public class GetComponentInParentExample : MonoBehaviour
</strong>    {
        // GetComponentInParent attribute can be used to automatically get the target component of the object's parent and set the variable with it
        [GetComponentInParent]
        public BoxCollider boxColliderOfParent;

        // You can set the param to true to create a new component in the object's parent automatically if there is none
        // --> [GetComponentInParent(true)]
    }
</code></pre>

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FKVFHpDE2tef6yBbrhdYu%2FGetComponentInParent.PNG?alt=media&amp;token=4232b877-e1ce-4c64-854e-7ef207998a62" alt="" data-size="original">

</details>

<details>

<summary>GetComponentInRoot</summary>

Takes automatically the target component in the object's root.

**Supported property types**

* Object Reference
* Exposed Reference
* Managed Reference

**Parameters**

* CreateOneIfEmpty

#### Limitations

Can't be used on arrays and lists.

<mark style="color:purple;">Code Example</mark>

```csharp
using UltimateAttributesPack;

public class GetComponentInRootExample : MonoBehaviour
    {
        // GetComponentInRoot attribute can be used to automatically get the target component of the object's root and set the variable with it
        [GetComponentInRoot]
        public BoxCollider boxColliderOfRoot;

        // You can set the param to true to create a new component in the object's root automatically if there is none
        // --> [GetComponentInRoot(true)]
    }
```

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FGJCMNKo33lQZzOREZc8W%2FGetComponentInRoot.PNG?alt=media&amp;token=764cae07-f399-4d91-9e97-236be18e0319" alt="" data-size="original">

</details>

***
