HoverState in RealityView

In a scenario involving one of the entities in a Reality Composer Pro environment, I intend for this entity to display a blue material when viewed by the user. To achieve this, I have added the following Shader Graphs to the materials associated with this entity:

Additionally, I have included the HoverEffectComponent component to the Reality View in the code:

        RealityView { content in
            if let model = try? await Entity(named: “WorldScene”, in: realityKitContentBundle) {
                let hoverEffect = HoverEffectComponent(.shader(.default))
                model.components.set(hoverEffect)
                
                content.add(model)
            }
        }

However, hover this entity, I am unable to observe any visual reaction. Could you please provide guidance on how to resolve this issue?

Answered by Vision Pro Engineer in 798435022

Hi @lijiaxu ,

Please see the documentation for HoverEffectComponent :

Entities also need to have an InputTargetComponent and CollisionComponent to receive hover effects.

Make sure to set both of those, and your hover effect should start working!

Let me know if you aren't able to see it. You may need to use findEntity(named:) to get an entity deeper within the hierarchy to set it on if not.

Best,

Sydney

Accepted Answer

Hi @lijiaxu ,

Please see the documentation for HoverEffectComponent :

Entities also need to have an InputTargetComponent and CollisionComponent to receive hover effects.

Make sure to set both of those, and your hover effect should start working!

Let me know if you aren't able to see it. You may need to use findEntity(named:) to get an entity deeper within the hierarchy to set it on if not.

Best,

Sydney

HoverState in RealityView
 
 
Q