Highlight or select entity in RealityKit

I'm in the process of converting my SceneKit game to RealityKit. In SceneKit I used to be able to mark nodes as selected by setting SCNMaterial.emission with a custom color. I can do the same with PhysicallyBasedMaterial.emissiveColor, but I'd like to keep my entitities unaffected by the scene lights by using UnlitMaterial. In SceneKit I can set a category mask to indicate what light should affect what node, but there doesn't seem to be such a thing in RealityKit. So at the moment it seems like I have to choose between being able to mark an entity as selected, or having entities unaffected by lighting, but not both.

Is there some effect or component I can use to mark entities as selected by applying some coloring regardless of the material used?

You're correct about this difference between frameworks. RealityKit doesn't offer light category masks like SceneKit does.

For highlighting entities with UnlitMaterial, consider these approaches:

  • Create a selection component that swaps between regular and highlighted versions of your materials
  • Add a thin highlight mesh as a child entity when selected (like an outline)
  • Use ModelEntity.model?.materials.enumerated() to temporarily replace materials during selection

The UnlitMaterial intentionally ignores lighting completely, so you'll need one of these workarounds rather than relying on emission effects for selection highlighting.

Highlight or select entity in RealityKit
 
 
Q