Public Array of GameObjects

Hey

I’m making a Multiplayer FPS and now i have a problem with my Weapons-Pickup-Script. In my game you can pickup weapons kinda like in actual fps like call of duty. So when you pickup a weapon you throw your actual equiped gun on the floor. For this reason i would like to have an array of GameObjects. It should be public so that i can drag my PickupWeaponsmodels right in it from the editor.

I searched for that a few times and find ArrayList but i didn’t manage to get a public arraylist done where i can drag my models in. I don’t even think thats possible. I also can’t add my Models through tags to such an arraylist because the tags of the models are used elseways.

Hope someone finds a way to solve my rather special question.

Use builtin arrays:

C#

public GameObject[] myObjects;

or JS:

public var myObjects : GameObject[];

Now you can access them in your script once you have them set. In the inspector you need to set the number of elements you need and then drag your game objects to each of your elements.
Access is done the regular way arrays are accessed. E.g.

function Start()
{
   for(var go : GameObject in myObjects)
   {
      Debug.Log(go.name);
   }

   //or like this
   for(var i:int=0; i<myObjects.Length; i++)
  {
      Debug.Log(myObjects*.name);*

}
}