Search Unity

How to add an image to a component

Discussion in 'Getting Started' started by KyleL144, Aug 10, 2019.

  1. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    136
    When you have created your new UI Image object and selected it in the Hierarchy, do you get the Image Component in the Inspector?

    If so, click on the small circle to open window where you can choose your image.

    upload_2019-8-10_15-41-12.png
     
  3. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
    Yeah i have got that, but when I click on the small circle to open the window, then all i get is the following:

    5.png

    And my image is not there/listed :/
     
  4. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    136
    If you saved the image into the Assets folder of your Unity project, you should be able to find it in that window.

    Check the Assets folder in the Project window to make sure your image is in there.
    upload_2019-8-10_17-20-34.png
    You can also drag the image from the Project window.
     
  5. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
    My image is in the asset folder as shown below:

    6.png

    But when i click on the small circle, then it is not listed and when I drag it then i get the symbol shown below:

    7.jpg
     
  6. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    136
    Download the image from the tutorial by right-clicking on Download Image.

    upload_2019-8-10_18-13-55.png

    Drag this new image to your Assets folder and use this one.
     
  7. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
    Done that and still can drag it or find in when i click on the small circle :/
     
  8. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    136
    Maybe you should start from scratch, because it works for me:
    upload_2019-8-10_18-37-26.png
     
    Last edited: Aug 10, 2019
  9. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
    Okay i'll try it later this evening
     
  10. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,550
    This is an interesting problem that stumped when Unity's UI came out but the solution is simple. If you look at the image component you'll notice that the "Source" entry has "None (Sprite)". The text between the parenthesis refers to the type of asset that it expects.

    By default when you import a 2D image into a project that is set up by default for 2D, the image will be a Sprite, but if you import a 2D image into a project that is set up by default for 3D, the image will be a Texture.

    Click the image asset in your project, in the Inspector change the "Texture Type" to "Sprite", and then click "Apply". Once you've done that you can set the image component to use the asset.

    upload_2019-8-10_16-55-5.png
     
    Last edited: Aug 10, 2019
    JoeStrout, Valjuin and KyleL144 like this.
  11. KyleL144

    KyleL144

    Joined:
    Aug 9, 2019
    Posts:
    21
    Thank you it worked