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 SVG vs. PNG / Spritesheet / Drawcalls / Performance

Discussion in '2D' started by TH_Devleopment, Jul 23, 2023.

  1. TH_Devleopment

    TH_Devleopment

    Joined:
    Mar 5, 2020
    Posts:
    3
    Hello,

    i've a general question about using SVG Sprites (Icons) in Unity3d. Usually i would use png SpriteSheets to reduce drawcalls, memory size and performance, but since unity supports vector graphics, i wanted to update myself in this matter. I have up to 300 svg icons i would like to use in my projects.

    My questions are:
    1. Does svg sprites as single files causes the same drawcall issue like 300 single png files?
    2. Do you have experience with svg files in general for mobile compatibility?
    3. Is it better to have 300 single svg files or some png sprite sheets for usage inside the project (in terms of memory size, the svg sprites would be a big advantage but - a lot of single files in my opinion)
    4. General thoughts and tips or general techniques for perfect graphics usage?
    Im looking forward for some exchange :)

    Thanks and best regards!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    AFAICT, it just makes a sprite when you import it.

    It isn't actually using the scale-less geometry of the original SVG, at least not in the version I looked at.

    Screen Shot 2023-07-24 at 10.38.35 AM.png


    When I enable the debug inspector (right click on inspector tab), I see these read-only fields.

    There might be more in the online docs for atlassing / combining / sprite-sheeting.


    Screen Shot 2023-07-24 at 10.40.12 AM.png


    You could always import it into Blender, turn it into a Mesh there (again choosing a curve tesselation quality level), save it as an FBX and import it...

    Personally I would just strike all your icons to a nice big sheet (or three) and use that. :)
     
  3. TH_Devleopment

    TH_Devleopment

    Joined:
    Mar 5, 2020
    Posts:
    3
    Hello Kurt,

    thank you for your contribution. In fact, placing the SVG images on sprite sheets would lead to various larger sprite sheets, since I want to avoid textures over 2k for mobile and the resolution must be sufficient to not have a loss of quality. The scalability of the svg files is a huge advantage.

    Furthermore, the svg files in unity are scalable without any problems, even if certain image components such as sprite swap for button are not supported (you would probably have to program that yourself)

    Is it possible to pack svg files in a sprite atlas?

    Edit: Yes it is, but its a bit difficult to get them into it :D
     
    Last edited: Jul 25, 2023