- Home /
Drag and Drop onto Array of Custom Objects
I would love to be able to drag and drop a long list of prefabs from the Project window onto an array of custom objects, each of which has a prefab field, and see the empty prefab fields populated with the long list of prefabs. To illustrate this, here is a screenshot of my array of Entity objects. Each Entity has a name, a GameObject, a color, and an offset.
I want to let the user select the two prefabs (at the bottom of the image) and drag them onto the words "Entities Array" and have it instantly look like this: Is there any way to accomplish this? (Please note that the only thing necessary to make the prefabs go into the right positions is alphabetical order. I'm not worried about matching up names.) Thanks!
there's one solution I can think of that might work one way or another, but you'll have to google the parts for it:
- create a custom inspector for your data type - make it show up as an array of gameobjects - make the folded out elements look like what you'd expect, either through the same editor script or an property drawer
I think this could work because when the array shows as just the gameobjects, it's drag droppable. but the single elements could show like the actual serialized type.
Your answer
Follow this Question
Related Questions
Getting a Reference to a Prefab Dragged into Scene 1 Answer
Problems With Variable Class Arrays... 1 Answer
Why cannot I drag and drop a gameObject from Hierarchy to a prefab's slot in the Inspector? 3 Answers
Editing properties of game objects inside an array using the inspector. 2 Answers
Add Elements in Array in Inspector with alphabetical sorting 4 Answers