Finding GameObject Index in a Generic List on another script C#

Hi all!

I’m unsure if my Logic is unsound or I am just not figuring out how to do this right. I’ve been searching through the Unity Forum, StackOverFlow and MSDN all week, and I think I am just plain missing something. I don’t have solid code examples for this , because I’ve been cobbling from examples, but don’t know if I am anywhere near the mark.

Script A has a list of Gameobjects populated by a Collider (ever changing).
Script B lives on all the potentially hit Game Objects, that provides variables I need for other things.

On Script B, I want to find out what Index position that particular object holds on the list on Script A, Then I want to find out what is in the slot right above it (so Index - 1) and have that object do something to the other one. I am sadly, really stuck on getting the Index position.

So example:

Script A

Script B
find out what position Cat is at
what Item is above it
Call another Script to do things.

However, the objects in the list continually change.

So how do I get the index of an the object script B is on, from another script?

IndexOf appears to be your desired approach.

Are there many objects in that list? Why don’t you go about it like this: when an object enters/leaves the list, just have your main script (the one with the collisions, ScriptA) notify the object immediately after the one that was added/deleted with the new object before it. That way you don’t need ScriptB to ask ScriptA about anything, it just does what it needs to do to the object it receives from ScriptA.

Thanks for the help guys!
I had already gone through all the links (as mentioned, I looked around for awhile before posting) and my issue ended up being logic based. Instead of getting the Index, I rewrote my script to send it the moment is gets populated in the list.

To answer the last question, at any point in time, there could be between 1 and 500 objects in the list at any point in time, but you threw me in the perfect direction for fixing my logic, so point to you Tehnique!