I’d like to use Unity to quickly flesh out game ideas, but one problem is that I am constantly wanting a building laid out for a prototype level. Problem is, doing this using Unity primitives is dull and long-winded.
How do you do it?
Tonight I built a system that creates levels from primitives using int arrays. Here’s a snippet from the highest level:
int[][] array = {
new int[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
new int[]{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1},
new int[]{1,4,0,0,0,0,0,0,0,1,4,0,0,0,0,0,0,1},
new int[]{1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,1},
new int[]{1,4,0,0,0,0,0,0,0,1,4,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,3,0,0,0,0,0,0,0,0,3,0,2,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
new int[]{1,4,0,0,0,0,0,0,0,1,4,0,0,0,0,0,0,1},
new int[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
BuildingGenerator.setPlayerObject(playerObject);
BuildingGenerator.addFromArray(this, 10, 2, 10, array, 5);
From that I get something like this: http://i.imgur.com/CALNm.png
1 is solid wall, 3 is a block plinth, 2 is the character start, 4 is lights, etc.
Which is fine, but because this is generated at runtime I can’t do fine detail (like adding small game objects, or playing with AI entities) or fiddle with the level pre-running it. Which defeats the object somewhat. Any suggestions?