Skip to main content
New Participant
March 22, 2025
Solved

Does the Focus Prompt option for CustomUI enter FocusedInteraction?

If a player clicks the focus prompt button that is built in with customUI, do they enter FocusedInteraction? Meaning could I use the CodeBlockEvent OnPlayerEnteredFocusedInteraction? Right now my assumption is no because it is not working for me, but I wanted to check in case my code is the problem.

 

  preStart() {
    this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnPlayerEnteredFocusedInteraction, this.onFocusedInteraction.bind(this));
  }

  start() {}

  initializeUI() {
    return View({
    });
  }

  onFocusedInteraction(player: Player) {
    console.log("onFocusedInteraction triggered");
    if (this.entity) {
      player.focusUI(this.entity, {
        fillPercentage: 0.4, 
      });
      console.log("UI focused successfully");
    } else {
      console.error("Entity is null or undefined");
    }
  }

 

 

PigeonNo12
Honored Contributor
March 24, 2025

That is correct. The focused interaction events (enter/exit) are not broadcasted when interacting with CUIs

Upcoming Events : Build with a Mentor: Custom UI Thursday 3/20 at 5:00 PM PT Register March calendar of all Mentor Workshops and Office Hours

7 replies

PigeonNo12
Honored Contributor
March 24, 2025

That is correct. The focused interaction events (enter/exit) are not broadcasted when interacting with CUIs

Upcoming Events : Build with a Mentor: Custom UI Thursday 3/20 at 5:00 PM PT Register March calendar of all Mentor Workshops and Office Hours
New Participant
March 30, 2025

Is there any way to identify when a user interacts with a CUI?

PigeonNo12
Honored Contributor
March 30, 2025

The methods of the Pressable node have a Player callback. You can use it to determine the player that is interacting with the button. For example:

onClick: (player) => console.log(player.name.get(), 'clicked'),
Upcoming Events : Build with a Mentor: Custom UI Thursday 3/20 at 5:00 PM PT Register March calendar of all Mentor Workshops and Office Hours
Shards632
Honored Contributor
March 31, 2025

the Player.focusUI() api is _different_ than Player.enterFocusedInteractionMode().  The act of 'zooming in' on a ui and the entering into focused interaction mode are two _different_ things.

That being said, while there _are_ events for entering/exiting focused interaction, there are currently _no_ events for zooming in/out of a Custom UI (or leaderboard, or quest board, etc).

June Programming Calendar
New Participant
March 31, 2025

I understand that. I'm trying to understand if any event fires that we can read when a user enter a custom UI within spatial display mode. Then, if there is, I would like the UI to have a different level of zoom when entered.

Shards632
Honored Contributor
March 31, 2025

there are currently no events fired for when mobile/web players 'zoom in' on a custom ui (or other in game UI element).  Good feature request, tho.

I think some people have come up with some interesting 'hacks' by tracking the position of the LocalCamera in a local script.

June Programming Calendar