Tag & Layer Mismatches

Unity’s Physics collision matrices, Rendering culling masks, Lightmapping bounds, and static batching mechanisms rely heavily on Tag and Layer configurations. A single mismatched object can break light baking or collision sweeps. The TagLayerRule audits child items against parent containers to enforce consistency.


Why Tag and Layer Consistency Matters

1. Physics Collision Matrix

If a parent group is set to Layer 8: EnemyCollider but a nested child GameObject is left on Layer 0: Default, the physics engine may not trigger collisions correctly, causing bugs where characters fall through geometry.

2. Camera Culling Masks

Performance optimization uses culling masks to hide distant props (e.g. Layer 12: Props_LowDist). If a prop child object sits on Layer 0: Default, it will draw at all distances, causing performance drops on mobile devices.

3. Lightmap Static Baking

Static meshes are grouped inside parent folders (like _STATIC_ENVIRONMENT). If a child mesh inside does not share the parent’s Static flags, Unity will exclude it from static occlusion and light baking calculations.


How the Rule Detects Mismatches

The TagLayerRule recurses through the scene hierarchy:

  1. It reads the tag and layer of parent folders.
  2. It compares them against nested children.
  3. If the parent folder name indicates a specific layer (e.g. starts with Layer_ or is explicitly defined in your project settings), it validates that all sub-objects match.
  4. If static flags or layers deviate, the scanner flags the object and displays the target layer correction.

Fixing Mismatches

  1. Run the Scan Scene command.
  2. Locate Tag/Layer Mismatch diagnostics.
  3. Click Fix to update the child object’s layer.
  4. You will be prompted: "Do you want to apply this layer change to all children as well?" Choose Yes to perform a recursive layer sweep, or No to update only the specific child object.

This site uses Just the Docs, a documentation theme for Jekyll.