Obtaining Component list

You must have valid GameObject pointer.

Via name:

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

Via pre-cached SystemType:

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:

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

Last updated