Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Writing on top of an inline sprite for displaying keys / buttons

Discussion in 'UGUI & TextMesh Pro' started by Daerst, Jul 18, 2021.

  1. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Hi there,

    I'm looking for a way to display a sprite, say an uncaptioned button, and then but some additional text on top of it to e.g. display the keys [ W ] [ A ] [ S ] [ D ] or controller buttons ( A ) ( B ) ( X ) ( Y ), all with the same uncaptioned sprite as background. So far it looks like I have two options: play with the sprite's Glyph Metrics and use a monospace font to write a single character right across it; or prepare captioned graphics for whatever keys I might need and put them into a sprite sheet.

    Being able to write a 'subtext' as caption on top of a sprite and have it nicely centered sounds like a very useful feature to me. The 'subtext' might be chars (ABXY) or might contain sprites in itself (looking at you, Playstation ∆×○□). Does something like this exist yet?

    Thanks!
    Daerst
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This will be possible in the next preview release of the TMP package by using / defining Diacritical Marks for the sprite glyphs.

    Check out the example in the following thread.

    In that example, the sprites are positioned relative to a character which is the same thing in regards to this new feature. In this case the Base glyph is the character and the sprite the Mark whereas for your use case, the sprite would be defined as the Base glyph and the character the Mark.
     
    Daerst likes this.