I am working a project which required a lot of 3d cubes to be placed on the ground. The final image looks like:
What I am doing is Create->3d cube → adjust position ONE BY ONE. Which took quite a mount of time. Is there any other quicker way to achieve this? Thanks!
Ben
While an editor script as mentioned before is an elegant solution, a more primitive way of doing things that doesn’t require writing a script would be to copy and paste large groups of cubes (e.g. entire rows). Simply select all of them in the hierarchy, use ctrl+d to duplicate them and use the standard transform tools to move them all at once.
Without giving anything away, you could use an ExecuteInEditMode script. It functions like a normal script, but also updates in the editor when the GameObject is selected.
You could loop through each cube and set its position to align to the grid, reset its rotation to Quaternion.identity, etc.
Other alternatives for custom in-editor scripting are MenuItem and EditorWindow.
"What I am doing is Create->3d cube → adjust position ONE BY ONE. "
Well, that should still be pretty fast. Wait… do you mean; “by hand”, in the editor?
If so, create a script to generate ALL the cubes for you, then easily select the ones you want to remove.
here is an untested/uncompiled example of a script like that. As Cresspresso mentioned, this should be an “editor-script”.