- Home /
Is it possible to drag/drop/increment into editor array?
I have an array, let's say it's of Texture2D, in my script. In the inspector, I first need to change the size of this array from 0 to something, then I get 'slots' onto which I can drag textures.
Is there a way to make it so I can just drag/drop textures onto this field and have it add the texture, without having to type in the number of elements? And if I drop more on there, it would add them to the list? Perhaps a Dictionary? Or can this be done with a custom editor?
Answer by Eric5h5 · Jan 31, 2014 at 08:49 AM
Just drag the textures onto the array; you don't need to create slots first. The cursor has a "+" when you do this, and it adds slots automatically as needed.
So simple, I never knew that! Learn something every day with Unity!
Just FYI - you can also select an array element and press Delete to delete it, Shift-Delete to clear it, and Command-D/Control-D to duplicate it to effectively insert another slot at that point in the array.