- Home /
Question has multiple technical issues and is too broad
How would you make an in-game editor/object spawner?
How would I make an in-game level editor. Just to quickly drag and drop objects into the scene from a menu, it's a mobile game, so two hands to rotate, etc. It is a similar system to creating your own skate park in Skate 3, if you've ever played it. So I just want to know where to start in doing all of this. Sorry if this sounded a bit complicated, but I'm fairly new to Unity. Thanks in advance.
This question involves multiple technical questions and is really a discussion question that belongs in the forum. The are many posts on this list that address the many parts of your question.
Answer by Tarlius · May 30, 2013 at 04:22 AM
I think you're asking a lot more than you realise in this question. For the title question (ie: object spawner), you'll want to look at Object.Instantiate() and prefabs.
public GameObject prefab;
public Create() {
GameObject instance = (GameObject) Instantiate(prefab, Vector3.zero, Quaternion.identity);
// etc
}
For the UI, you could get a simple prototype going with the GUI class, but since its for mobile you'll probably want to use something from the Asset Store. I don't know what the cool kids are using these days, but we're using EZGUI moving towards NGUI here.
I seem to recall there being gesture support ("two hands to rotate") built into Unity, but a quick google turned up a blank. You'll probably be better off starting very simple though. Press one button to "create" the object, then have up down left right buttons to move.
Dragging will be a little more involved, but if you code the basics with the intention of expanding later, it should be doable. For example, instead of "moveUp", "moveDown"/etc, use "MoveTo(x, y)" and have another class managing the buttons and working out where to MoveTo. You can then replace/supplement later with a class that implements the drag logic.