Level Editor That's Not Constrained to Tiles

I’m trying to make a level editor that isn’t constrained to tiles, similar to the one in Geometry Dash. While objects will be placed on a grid, they can also be moved freely (so basically a sprite based level editor).

I’m currently using Graphics.DrawMeshInstanced() to draw the objects. However, I can’t find a simple way to do physics with them. Is there a performant way to put a collider on each mesh? I could search for the player with raycasts from each object, though that’s not nearly as elegant as the other way around.

I could also make each object its own gameobject, though I’m afraid that might cause performance issues. I’m trying to make the editor as efficient as possible, hopefully allowing there to be thousands of objects on screen at once.

I don’t understand why you don’t just make prefabs and place them in the scene instead. I have honestly never heard of this DrawMeshInstanced function in 2D, so I can’t say anything about it. But it’s definitely not how anyone I know would do this.

As @Zephus points out, that is what Unity already IS: a free-form scene editor.

Keep in mind you may benefit greatly by making little scripts and tagging them onto interesting parts of your created scene, such as exits or dangers or health or whatever. That’s how you power-multiply the already-awesome freestyle editor that is Unity3D.

Huh, sounds new-fangled and whacky. Something wrong with just dropping sprites or geometry in and being done with it?

Amen Zeph.

Sorry I didn’t specify. I’m trying to make a runtime editor. And like I’ve said, I’d like for it to be as efficient as possible.

I’m trying to recreate the level editor in Geometry Dash, and levels with hundreds of thousands of objects in that game are not uncommon. From my experience using prefabs, I’ve only been able to get about 2000 gameobjects on screen doing collision before dropping below 60fps, which isn’t bad at all, but I can get > 30,000 with the other method.

Clearly something was wrong with my testing before. I tried instantiating prefabs and have been able to get > 10,000, which is a good enough amount. What I might end up doing, if performance becomes a problem, is manually draw the meshes for objects that don’t need collision, and use prefabs for the ones that do.

Assuming you don’t need to zoom out more than a certain instance, the traditional way to handle this is to store the positions of the objects and only instantiate GameObjects / Prefabs for what is visible in the editor at any given instant.

You’re gonna have to do this when you’re playing it obviously, so it makes sense to just couple the editor directly together with the level streamer, so you don’t end up maintaining two codebases.