Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

dynamically vertically center text

  • #1, by nicolas-dekaise 2 years ago Zitieren
    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
  • #2, by meant-awful 2 years ago Zitieren
    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.

  • #3, by nicolas-dekaise 2 years ago Zitieren
    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?
  • #4, by esmeralda 2 years ago Zitieren
    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")