Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Using PNG Image as Image in User Interface

Discussion in 'UGUI & TextMesh Pro' started by bcoppens, Jan 7, 2015.

  1. bcoppens

    bcoppens

    Joined:
    Jan 7, 2015
    Posts:
    7
    Hi,

    I'm following my first tutorial and I want to add an image to the UI (this image is like a score button)
    It shuld be fixed in the upper left corner.

    I have the PNG imag added to the assets folder. So far I've come accross many different answers. And one of those was to make a GUITexture. However I don't find the path that was mentioned: GameObject --> Create Other: GuiTexture. Another option was to drag it onto the scene and change the inspector properties to GUI.

    But it seems a lot has changed in the interface of Unity and all this doesn't work anymore.

    Can anyone tell me how to add my PNG image in the corner of the User Interface? (I read something about scripting but I would prefer without it, like it was before with the createOther:GuiTexture)

    Thanks.
     
  2. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    828
    Which unity version?
    4.6 and above uses a new gui-System.
    Create -> UI -> texture and drag your png in the image slot. You have to Import your png as "sprite (2d and gui)" or something similar.
     
  3. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    197
    With new UI system you just need to set the PNG import settings texture mode to Sprite. Then you can just use them directly with for example Image objects.


    Edit: What the person above me said :)
     
    Abb7 and ParthoBiswas007 like this.
  4. bcoppens

    bcoppens

    Joined:
    Jan 7, 2015
    Posts:
    7
    Version 4.6.1

    But I don't find the Create --> UI --> Texture in the menu. Is this under gameobjects, assets?

    I click import assets and choose my PNG file, but I don't see the option to import it as sprite?
     
  5. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,327
    I came here because the title said "ass Image", but after reading the thread, I don't understand why those words are even in the title. :confused:
     
  6. bcoppens

    bcoppens

    Joined:
    Jan 7, 2015
    Posts:
    7
    changed. But anyone who has a comment on my latest answer to help me further?
     
  7. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,327
    That makes way more sense!

    Create, at the top of a Hierarchy panel, is another way to access a set of functions that you can view by right clicking in the hierarchy panel or opening the GameObject menu from the top of the screen.

    However, the thing you want is called Image, not Texture. But the title of the thread suggests that you know that already.
     
  8. bcoppens

    bcoppens

    Joined:
    Jan 7, 2015
    Posts:
    7
    hehe thanks :)

    Ok so I did create image then and now I have a white image there. So how can I use the PNG image I made that should serve as part of the UI now? (are you sure I shouldn't use a texture for this because the image is already made in another program)

    My image doesnt appear under the sprite assets.
    I tried rawimage and then I can choose the PNG but it doesnt look high quality anymore. How come?
     
  9. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    828
    Choose image instead of rawimage and in your project folder click on your texture. There is a dropdown at the top of the inspector, "texture" is preselected, click on it and select Sprite (2d or UI).
    After that, you should be able to drag your texture (sprite...) into your "Image"-gameobject.
     
  10. nileshkumawat

    nileshkumawat

    Joined:
    Oct 20, 2018
    Posts:
    1
    what is the easiest way of importing a png image into unity and use it as a sprite for image ui?
     
  11. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    828
    Drag it into your project folder and change the type to "Sprite (2D and UI)", nothing changed about that.
     
    shadowFire4444 likes this.
  12. dwivedykrish14

    dwivedykrish14

    Joined:
    Jul 26, 2020
    Posts:
    1
    How do i import a pic from from good PNG and turn it into a sprite for a background.
     
unityunity