Brackys Inventory Program Specific Line of code

I have looking though the scripted (Converted to C#) and I dont understand this line.

	Transform[] Contents; //The content of the Inventory

Ok this is the content of the inventory fair enough. (Im gussing by content they mean the items stored in the inventory, Sword, Helmet, Rotten Fish etc) Yeah im having a dumb moment…:(:face_with_spiral_eyes:

I understand its a type of variable, but I dont understand the variable type.

I know Transform is used in 3D space but what has that got to do with a inventory? I run after my bag thats been blown away by the wind

Also the [ ], I know that has something to do with Arrays, at college we’ve only just gotten started on these.

So what does this variable type mean?

I’m unfamiliar with the tutorial you mentioned, but…

 Transform[] Contents; //The content of the Inventory

That’s specifying a new variable (Contents) that’s designed to hold an array of Transform objects. Why an array of transform objects? I’m not sure without seeing the tutorial, but most likely because the code is mostly interested in accessing properties of the Transform component associated with the inventory game objects. From an array of transforms, it’s still easy to get to the containing GameObject if / when that’s necessary. For instance, Contents[0].gameObject will still provide access to the containing GameObject of the first transform in the array.

So, that would be typical of code that generally wanted access to the Transform related data of a group of objects, while still allowing simple access to the containing GameObject or other components on that GameObject.

Jeff