> For the complete documentation index, see [llms.txt](https://sneakyevil.gitbook.io/il2cpp-resolver/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sneakyevil.gitbook.io/il2cpp-resolver/gameobject/obtaining-component-list.md).

# Obtaining Component list

{% hint style="warning" %}
You must have valid GameObject pointer.
{% endhint %}

### Via name:

```cpp
Unity::il2cppArray<Unity::CComponent*>* m_pComponents = m_pObject->GetComponents("UnityEngine.Component");
```

### Via pre-cached SystemType:

```cpp
Unity:il2cppObject* m_pSystemType = nullptr;

void InitSystemTypes()
{
    Unity::il2cppClass* m_pSystemTypeClass = IL2CPP::Class::Find("UnityEngine.Component");
    m_pSystemType = IL2CPP::Class::GetSystemType(m_pSystemTypeClass);
}

Unity::il2cppArray<Unity::CComponent*>* m_pComponents = m_pObject->GetComponents(m_pSystemType);
```

### Looping through list:

```cpp
for (uintptr_t u = 0U; m_pComponents->m_uMaxLength > u; ++u)
{
    Unity::CComponent* m_pComponent = m_pComponents->m_pArray[u];
}
```
