How to drag in gameObject to public gameObject array property

This is probably a silly question, but how am i supposed to drag in a game object to a public game object array in the Unity editor???

I really can’t figure it out


When i try to change size, it just changes back to 0

public variable declaration:

public GameObject[] Hazards;

Little video

Please help. thanks

An array needs it’s size initialized before it can be used. What you can do is click into the size property where the 0 is and change it to however large you need. If you are having an issue doing this, make sure you press enter after you change it. Sometimes the editor is a bit finicky and resets a value if you don’t press enter.

Once you change the size, you’ll see several slots open up below (the same number as you just typed in) and you can then drag your object into those slots.