dynamically vertically center text

  • #1, by nicolas-dekaiseTuesday, 27. February, 16:18 9 months ago
    Hi everybody,

    I've a cutscene with narration text, It's centered horizontally, no problem with that, but is there a way to center it vertically ?

    My first idea was to hook a script to "setTextPosition" that will get the length of the string and roughly calculate how much I need to adapt the y position.

    I tried to access ActiveTexts.CurrentText but it's always empty

    Thanks in advance smile

    Newbie

    7 Posts


  • #2, by meant-awfulWednesday, 28. February, 04:57 9 months ago
    Hi everybody,

    I've a cutscene with narration text, It's centered horizontally, no problem with that, but is there a way to center it vertically ? https://basketrandom.pro

    My first idea was to hook a script to "setTextPosition" that will get the length of the string and roughly calculate how much I need to adapt the y position.

    I tried to access ActiveTexts.CurrentText but it's always empty

    Thanks in advance smile
    You can try add a UI text element to your canvas where the narration text will be displayed. Ensure that the text element is set to "Center" alignment horizontally.

    Newbie

    1 Posts

  • #3, by nicolas-dekaiseWednesday, 28. February, 14:46 9 months ago
    Hi,

    Thanks for your answer smile

    But I'm not sure I understand, I know how to use UI and Canvas in Unity, but I'm new in Visionaire Studio, and it seems to me that there's nothing like Canvas in Visionaire, am I wrong?

    Newbie

    7 Posts

  • #4, by esmeraldaFriday, 01. March, 12:34 9 months ago
    I think that was a bot who answered you. (there is a link inserted in the quote)

    regarding centering the text:
    If you look in the wiki for community made scripts there is an example for positioning texts.
    https://wiki.visionaire-tracker.net/wiki/Change_Text_Position

    possible solution:
    function txtPos(text)
      if text.Owner.tableId == eGame then   -- text is narration text
        -- Define the new text position on the screen
        text.Position = {x = game.WindowResolution.x/2 + game.ScrollPosition.x, y = game.WindowResolution.y/2 + game.ScrollPosition.y}
        return true
      end
      return false
    end
    registerHookFunction("setTextPosition", "txtPos")

    Key Killer

    533 Posts

Write post