Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Displaying an image on screen

Discussion in 'Scripting' started by julien83franceschi, Jun 3, 2023.

  1. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    178
    I'd like to place an image in the scene.

    I opened Gimp 2.10, selected my white arrow (with the magic wand), copied it, then pasted it as a new image.
    This gives me the image below.



    Then I saved it with "Export as".
    I unchecked "save background color" and checked "save gamma".

    The problem is that when I import the image into the Project panel (in Unity), my image is no longer transparent and when I click and drag from the thumbnail in the Project panel to the scene, the cursor displays a cross.

    I've also tried to place my thumbnail in an image, but again the cursor displays a cross.

    Your help is most welcome,

    A+
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Did you set the transparency / alpha import settings properly? Post a screencap of the import panel for that image.
     
  3. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    178
    Hello,

    I've checked the "Alpha is transparency" box,

    I'll let you see my images (they're worth more than a long speech):

    -here:



    -and this:



    Thank for your help,

    A+
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    And how are you displaying this image in your scene?

    Some possible answers:

    - as a sprite

    - as a UI image

    - as a quad with an appropriate shader

    Something else?
     
  5. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    178
    Hello all,

    If I've understood correctly, sprites are created automatically when you click and drag a thumbnail in the scene.

    In my case, it displays a cursor with a cross.
    Like when I try to put the thumbnail in a UI Image.

    Maybe it's a Gimp error,
    I described everything in the first message.

    Thanks for your analysis,

    A+
     
    Last edited: Jun 3, 2023
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Then import it as a sprite, not as "Default"

    You really should spend a little time reviewing the docs:

    https://docs.unity3d.com/Manual/class-TextureImporter.html

    EVERY setting has a purpose. Nothing is "by accident," even if some of it does not apply in certain cases.
     
  7. julien83franceschi

    julien83franceschi

    Joined:
    Nov 14, 2020
    Posts:
    178
    I followed the following tutorial:

    https://docs.unity3d.com/Manual/TextureTypes.html#Sprite

    And here's the result:


    The problem is that, as you can see, my sprite isn't transparent at the rendering.

    If you have any ideas (Gimp or others, export settings, transparency).

    Thanks again,

    A+
     
    Last edited: Jun 3, 2023
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Find out if your image is transparent. Review Gimp steps for how.

    The attached PNG has transparency for sure. Make a sprite, drag it in.
     

    Attached Files: