If you make a public array class member in Unity, you can individually assign objects to the array in the inspector menu. It looks like this:

enter image description here

However, this is cumbersome if you you want to assign the same array to many objects. It's easy to do this programatically, but I'd rather not hard-define the array in code - it makes moving/renaming the objects harder.

If I want to pass the same array to multiple game objects, how can I do it more efficiently than dragging each individual element into the inspector?

  • 1
    \$\begingroup\$ Creating a ScriptableObject that contains the array (and optionally other shared data) will let multiple instances share one copy. That means not only do you only have to edit it once, but it also exists only once in memory, no matter how many objects reference it (unless they manually instantiate their own local copy). The shared data becomes an asset on its own, which can be versioned independently of the objects referencing it. If that's suitable for your needs I can write up additional details in an answer. \$\endgroup\$
    – DMGregory
    Jul 18, 2015 at 6:18
  • \$\begingroup\$ I was actually wondering if there was a solution like that - make an asset that just contains the array and share it among objects. Sounds promising. \$\endgroup\$
    – Chaosed0
    Jul 18, 2015 at 17:51
  • \$\begingroup\$ @Chaosed0 you can actually create custom assets. That take a look at ScriptableObject and do a google search: jacobpennock.com/Blog/… \$\endgroup\$
    – Ricky AH
    Jul 18, 2015 at 22:14

2 Answers 2


You can actually add multiple items to an array in one go. Just lock the inspector with the GO that contains the list, select the multiple gameobjects and drag & drop them into the inspector. No need to do anything special.

  • \$\begingroup\$ Oh hey, would you look at that. I think I may have tried to do this, but I was not locking the game object into the inspector. \$\endgroup\$
    – Chaosed0
    Jul 19, 2015 at 0:13
  • \$\begingroup\$ Life saving technique! \$\endgroup\$
    – livingtech
    Nov 9, 2016 at 17:54

It sounds like you might want an editor script:


You could place a button on your object's inspector that would take the current scene selection (http://docs.unity3d.com/ScriptReference/Selection-gameObjects.html) and set the values to be the contents of your array. Doing it this way would require that you select the object, lock the inspector to that object, then select all the explosion pieces you want, and press the button on the inspector to load the selection into the prefabs array.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .