Get Component based on Inspector order?

Hi everyone!

I have a GameObject with two BoxColliders and want to access the first BoxCollider (in the inspector-list) via Script. Is there a way to do that? And if not, can I make an if-else statement, that lets you get the BoxCollider, that !isTrigger?
Thanks a lot! I’m looking forward to your answers.

link:What I’m talking about

Hi @SmaiStudios ,
you can get the first component in this way:

BoxCollider[] colliders = GetComponents<BoxCollider>();
//index zero is for uppest boxcollider in your gameobject but you can find it // with iterating through all colliders
            foreach(var c in colliders)
            {
                if(c.isTrigger)
                {
                    //you 've found it

                }
             
            }