r/Unity3D • • 8d ago

Question Markers vs. GameObject names in a modular building system

Hey, a while ago I shared some early work on "MODURA", my stylized modular building creator for Unity Asset Store. I've been working on its editor tools since then, and one thing I wanted to avoid was relying on GameObject names to identify individual parts. Names like "Window_01" or "Door_03" work fine at first, but I didn't want things to break just because someone using the asset decided to rename a few objects.

So I went with dedicated marker components instead. Each part has a component that tells the tools what it is, which the editor tools use to determine what can be done with it. It's a bit more setup, but I prefer this over having the tools depend on specific names.

How do you usually handle this in your own tools? Do you use marker components, naming conventions, or something else?

47 Upvotes

13 comments sorted by

3

u/Federal-Row2373 8d ago

Marker components feel like the safer call for an asset other people will use, since names are the first thing users change when they organize a scene. One thing I'd wonder about is custom parts: if someone drops in their own window mesh, do they have to add the marker by hand, or do the tools offer to tag it for them? That first-time setup step seems like where users would get stuck, more than the marker idea itself.

1

u/OverqualifiedMesh 8d ago

The tools use markers to identify parts, and configured asset folders to find the prefabs they can add or swap in. So if someone adds a custom window, they’ll need to add the appropriate marker themselves; the tools don’t tag it automatically. I’ll make sure to document this for anyone who wants to add their own content and extend the pack.

1

u/goddessBlushh 8d ago

markers are definitely the move when other people are gonna mess with your stuff. you sound like the type that would tag those customs parts for me without making it weird

1

u/OverqualifiedMesh 8d ago

That's a great idea. I'll just set up a place for everyone to dump their custom parts and spend my days tagging them. Sounds like a plan 💪😉

0

u/flirtyMuffinn 7d ago

yeah markers beat names every time for that reason. the custom part tagging does sound like the spot where it could get clunky though, you got any tricks for making that smoother?

1

u/OverqualifiedMesh 7d ago

For now - user documentation explaining how to do it, although in my case it seems to me that this is quite a rare case and users will be more likely to wait for content from the package developer than try to create some elements themselves that will be inconsistent with the rest.

1

u/OverqualifiedMesh 7d ago

+ you could create a script with a suitable UI to handle the behind-the-scenes work that currently has to be done manually. It could use the appropriate fields in the tool that adds new variables to the markers, or automate adding new prefabs. But for now, that would probably be overkill for something no one would use anyway.

3

u/jackbrux 8d ago

I would create a catalogue prefab/scriptable object, and assign prefabs and give them a name or other metadata just inside that catalogue.

I find that often you may need to assign the same object to different catalogues with different metadata.

Your approach is good if there's a tight coupling between the object and the metadata

2

u/OverqualifiedMesh 8d ago

That makes sense. In MODURA, I handle it a little differently: prefab has a marker with dropdowns for the metadata the tools need. For example, a window prefab’s marker stores its size, and the variant tool uses that to find compatible prefabs in the configured folders. The folder config tells the tool where to search; the marker tells it what each prefab is. So the idea is similar, but I store the metadata on the prefab rather than on each catalogue entry. Your catalogue approach could be more flexible if the same prefab needed different metadata in different contexts. That’s my understanding of the difference, but please correct me if I’ve got it wrong.

1

u/TheSensitiveCat 4d ago

After working on a number of similar systems, this is the approach I usually go for. I’ll typically use an SO with generic tile data (dimensions / category flags), set reference to the tile prefab without any extra components, and plug that SO in to some catalogue / weighted deck. I find this allows for more flexibility if you want to reuse a tile in different contexts where dimensions or placement rules might be modified.

1

u/Capri-corn-studio09 7d ago

How do you handle renaming a module? Does placement depend on its GameObject name, or can an explicit marker keep the connection rules intact?

1

u/OverqualifiedMesh 7d ago

Renaming a GameObject doesn’t affect how MODURA’s tools identify building parts; they use marker components rather than object names. The building prefab is organized into marked sections such as Front, Length, and Back, with nested floor and wall prefabs inside. For example, LengthSegment identifies the repeatable section used when changing the building’s length. FloorMarker identifies the ground floor and the base floor that gets duplicated to add upper floors, while RoofMarker lets the tool reposition the roof. Windows, doors, and balconies also have their own markers, which the relevant tools use to identify those objects. As long as the markers and prefab hierarchy stay in place, renaming the GameObjects won’t break those tool behaviors. The markers define how MODURA’s tools operate on the building; they aren’t a general-purpose module connection system.