Populating a list with multiple GameObjects

Hello

My gameobject’s are subscribed to an event that when called, passes the gameobject to a static method which takes care of disabling and hiding that gameobject. The static method also adds that gameobject to a list so I can keep track of the disabled gameobjects.

My question is when I call this static method on multiple objects at the same time.

  1. How is the order to which they are added to the list decided?

  2. Is a list the best way to keep track of them?

I’m thinking about storing the transform of the gameobject before it is disabled, so when I come to enable it I can set it back to it’s previous position.

I will add that I haven’t use static methods or variables often, but I would like to be able to see the list of gameobjects in the inspector. Since the method is static I made the list static, from my understanding of static variables that would make sense as I don’t need multiple instances of this class( correct? ), but static variables don’t show up in the inspector.

  1. Should I make them non-static and create an instance of the class at start time?

Thanks

1.) How do you call the method “on multiple objects at the same time”?
Is the method called by events that are fired by Unity for multiple objects “at the same time” (such as OnBecameVisible, if several objects appear within the same frame)? If so, the order in which objects are added to the list is the order in which the events are fired, which I’d consider to be undefined.

2.) Sure, a List is fine – unless you’re dealing with vast amounts of objects, you’re not going to find anything noticeably more efficient.

3.) Consider making a Singleton of sorts: Have an instance of the class attached to a GameObject, but make the instance register itself as a static variable. Have a static method that returns this variable, and use that (rather than Find()) to access your instance.