Search Unity

How to load builtin UI sprite?

Discussion in 'UGUI & TextMesh Pro' started by nbg_yalta, Feb 24, 2015.

  1. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    There is a buit in sprites for UI (Background, Checkmark etc..) How can I load them and assign after creating an Image runtime, because it's null by default?
     
    howong likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
  3. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    I know about drawcalls, but I need this for the editor script and thanks, its just what I was looking for.
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
  5. elehelvari

    elehelvari

    Joined:
    Apr 10, 2015
    Posts:
    18
    Is it possible to get these built in images to see how they are created, so you can then modify them and put in your own sprite sheet?

    Of course it should not be complicated to create a simple 32x32 button, one similar to the UISprite, but I am actually having trouble recreating the built in one.
    I have tried many different resolutions, line width, rounded corner radius and different border width when splitting the button in the sprite editor.
    I believe my sprite looks very similar in the preview, yet in the game it looks much different then the built in UISprite.

    uisprite.png

    Why is this?
    Are the built in assets available somewhere?

    Thanks in advance,
    elehevari
     
    JackofTraes and Inannani like this.
  6. elehelvari

    elehelvari

    Joined:
    Apr 10, 2015
    Posts:
    18
    Turning off the Fill Center shows quite a difference between my version and the built in UISprite: it seems to have half the corner size. I'll try experimenting with that, hoping I get closer to the built in version.
    fill center off.png
     
  7. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @elehelvari: hi - not sure why toggling fill center on/off would make any difference, your texture is quite coarse, and lacking AA thus it looks different.

    If Unity original texture is 32x32, then, if your corner chamfers look larger/smaller, it can be that your texture import settings have different pixels per unit (what ever it's called) setting.

    Didn't read full post, sorry if I missed the point.
     
    JackofTraes and Inannani like this.
  8. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @SimonDarksideJ : I see that you have a clever way to get default textures! Would it be possible to copy those textures and write them to files? Or are those files read only... just asking out of curiosity! Not sure if those are in files or in some DLL or something like that.

    Either way, it would be quite easy to create clones of those textures, if one needs to have them in one texture sheet.
     
  9. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    I believe the standard images are packaged up inside unity, probably for speed or compression. SO you can't get them from disk.
    You could export them but they are very basic.

    If you are having problems with different image qualities, remember the built in images use mipmaps, if yours dont then be sure to turn off mipmap generation to improve quality
     
  10. ClayBudin

    ClayBudin

    Joined:
    May 10, 2017
    Posts:
    6
    I'm pretty sure you are seeing a difference because the Unity images have Image Type set to Sliced, so that the various pieces of the image are applied separated (corners, edges, center) rather than just scaling the image as a whole. So the corners and edges remain small and tight while the center expands to fill the available space.