Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How to use same sprite image to game and UI?

Discussion in 'General Graphics' started by codeedward, Feb 28, 2015.

  1. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Hi I have problem with my images.

    For example I have one image named 'coin'. Texture Type is Sprite and it is ok when I use it like to Sprite Render component. But.. when I try to using same file to RawImage component in my UI, it looks strange.

    What I wanto to do? Just to have only one file and use this file in game and UI also. Any ideas?

    Strange look in UI:


    Inspector look:
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Why do you need to use the RawImage component? You can just use the image component and use the same sprite you are using for your Sprite Render.
     
    codeedward likes this.
  3. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Yeap, You are right! :) I do not know why I used RawImage. Probably some time ago I had the opposite situation - use Textures for Image component and it looks bad so I change component to RawImage.
    Thanks for help! :)
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    @fffMalzbier - It appears the strangeness in the OP may be due to no padding in the sprite as shown in the inspector window above rather than the change in image file type.
    Please correct me if I'm wrong. Thanks for clarifying.