Search Unity

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:
    842
    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.
     
    JamesAlger and vegn like this.
  3. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    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 :)
     
  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,325
    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,325
    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:
    842
    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:
    842
    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.
     
    SebastianHepp06 likes this.
  13. Neveloy

    Neveloy

    Joined:
    Mar 7, 2022
    Posts:
    1
    Worry not i got you.

    1. first import your png file in unity. You can do it by just dragging it from the folder to unity project screen [the part where you can see scenes, materials and stuff].

    2. now select the image. In the inspector, you will see texture type it will be set to default. Tap it and set it to sprite(2d and ui)
    and there you go, it is that easy all you have to do is change just 1 thing. Now u will be able to drag it into the section where the image goes.