Search Unity

How to generate an image with a text over it?

Discussion in '2D' started by engelcj, Oct 3, 2016.

  1. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
    I want to generate an image with a text that show the score over it, something like this games when you share the score:


    and this:


    I appreciate any idea, thanks.
     
  2. WinCisky

    WinCisky

    Joined:
    Sep 21, 2015
    Posts:
    8
    Create an UI Canvas and add an Image and a Text
     
  3. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
    But how I can convert this to png or jpg?
     
  4. WinCisky

    WinCisky

    Joined:
    Sep 21, 2015
    Posts:
    8
    A Canvas is a GameObject, you can't convert to jpg or png. Instead you can add an image to it in order to show it in the Scene (at the position that you want).
     
  5. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
    I know that, but I need that the image not appear in the scene, I need a way to generate an image with the text over it without showing it.
     
  6. absolute_disgrace

    absolute_disgrace

    Joined:
    Aug 28, 2016
    Posts:
    253
    I'm failing to understand what exactly you are trying to achieve? You want to create an image, not shown to the player, that has the score and the pre-defined other picture? How often do you want to generate this image? Is it on 'fail' or every frame?

    Part of the reason for asking is you may be attempting to do something to achieve a goal that can be done in a much more efficient manner.
     
  7. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
  8. absolute_disgrace

    absolute_disgrace

    Joined:
    Aug 28, 2016
    Posts:
    253
  9. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
    Yes I know, but if you play the game not only take a screenshot, also have text like the name and the score and this doesn't appears in the game, in other words, take the screenshot add the text with the name and the best score over it and showing all this together when you decide to share.
     
  10. absolute_disgrace

    absolute_disgrace

    Joined:
    Aug 28, 2016
    Posts:
    253
    You could simply create all that in the UI, display it for a single frame and take the screenshot then hide that information.
     
    engelcj likes this.
  11. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
  12. engelcj

    engelcj

    Joined:
    May 20, 2014
    Posts:
    122
    Researching a little bit I get the conclusion that the best way it is like @absolute_disgrace said, thanks so much.
     
    absolute_disgrace likes this.