Forum Discussion

LeahElanaa's avatar
9 months ago
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");
    }
  }

 

 

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

7 Replies

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

    • LeahElanaa's avatar
      LeahElanaa
      Member

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

      • PigeonNo12's avatar
        PigeonNo12
        Partner

        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'),
  • 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).

    • LeahElanaa's avatar
      LeahElanaa
      Member

      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's avatar
        Shards632
        Mentor

        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.