# Obtaining list

### Via name:

```cpp
Unity::il2cppArray<Unity::CGameObject*>* m_pObjects = Unity::Object::FindObjectsOfType<Unity::CGameObject*>("UnityEngine.GameObject");
```

### Via pre-cached SystemType:

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

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

Unity::il2cppArray<Unity::CGameObject*>* m_pObjects = Unity::Object::FindObjectsOfType<Unity::CGameObject*>(m_pSystemType);
```

### Looping through list:

```cpp
for (uintptr_t u = 0U; m_pObjects->m_uMaxLength > u; ++u)
{
    Unity::CGameObject* m_pObject = m_pObjects->m_pArray[u];
}
```


---

# 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://sneakyevil.gitbook.io/il2cpp-resolver/gameobject/obtaining-list.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.
