Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

SVG Importer | Vector Graphics | Unity UI Supported [OPEN SOURCE]

Discussion in 'Assets and Asset Store' started by Jaroslav-Stehlik, May 4, 2015.

  1. LoekvanKooten

    LoekvanKooten

    Joined:
    Apr 3, 2017
    Posts:
    120
    Is there any way to tell the renderer to show only the first path, the first and the second path, etc. for all path id's mentioned in the SVG DOM file? I need to build up my meshes one by one (this is to show stroke animations for Japanese characters). I assume it's too late once the whole SVG has been converted to a mesh after import, but building up to dozens of separate SVG files (one for each stroke, and that for thousands of characters) for one asset seems a bit overkill. There's a layer box I can tick and I'm not sure whether that's the same thing (I'm pretty new to Unity and programming in general), but even then I have no idea how to control these layers.
     
    Last edited: Apr 3, 2017
  2. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    44
    I don't see a reason why it wouldn't work, as long as the source doesn't have a lot of elements that this plugin doesn't support... even then you could likely just strip them out.

    Sidenote: I haven't had any problems with Illustrator since I started using this plugin to export the svgs.
     
    Th0re likes this.
  3. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    39
    Thanks for the tip. Just tested this, and looks interesting! I'll probably use it for quick exports of layers.

    I'm currently using a script in AI called "Multi Exporter" which also exports layers into a separate SVG files, but gives you options like adding suffixes to the resulting files (which is useful for my purposes).



    My pipeline thus looks like this:
    1. Work in the AI master only. Never touch any SVG.
    2. Keep relevant items together in one master file as far as useful. For example, different trees, rocks, ground parts that belong into a "forest" stage can be kept in "Forest.ai". Each character has one file etc.
    3. In Illustrator, pick File > Scripts > MultiExporter and export into a temp folder as SVGs.
    4. The exporter allows to export either one layer, or all layers, but sometimes I changed a few. I then export all, then pick what I need from the temp folder and move it to the asset folder proper. Another benefit of the temp folder is that you can double check naming conventions and such.
    5. After having moved the filesto the relevant folders in assets, I destroy the temp (the point is not to get attached to the SVGs, but always have the process flow from the master file).
    I believe I got the Multi Exporter from here, but you might want to search for other/newer versions.
     
    shaneparsons likes this.
  4. Arlorean

    Arlorean

    Joined:
    Sep 7, 2014
    Posts:
    27
    Using Unity 5.6.0f3 (64 bit) for PC Standalone <DX11> with SVG Importer 1.1.3 I get a couple of obsolete errors for Mesh.Optimize() and a shader error:

    Shader error in 'SVG Importer/Standard SVG': invalid subscript 'tangentToWorldAndPackedData' at Assets/SVG Importer/Plugins/Shaders/Standard/UnitySVG.cginc(120) (on d3d11)

    Any chance of a fix?
    This asset has been amazing in the past. Unity has pulled the rug from under you on this one.
     
  5. tacoilluminati

    tacoilluminati

    Joined:
    Oct 30, 2015
    Posts:
    6
    In 5.6.0f3 I'm getting some serious issues with creating new UI, everything looks all cut up and half transparent. Old UI elements created before 5.6 don't have any issues, even when removing and replacing SVGAssets from SVGImages. Not sure how to resolve it...

    This is a flat white rounded rectangle SVG that works totally fine with prefabs made before 5.6, and totally jank in prefabs made in 5.6

    Edit:
    Ah, of course I figure it out immediately after posting.
    Make sure your newly created canvases have their "Additional Shader Channels" to include TexCoord1, Normal, and Tangent!
     
    Jaroslav-Stehlik and Th0re like this.
  6. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    44
    Ah right on. I can't remember if I tried that one before, although it looks familiar.

    Before I found the plugin that I made note of, I constantly had problems with all exporting methods (even native illustrator export), as they were all generating certain decimal numbers in the svg that svg importer couldn't parse. As long as you're not getting 'corrupted svg' errors on every svg, then it's probably safe to say your plugin works.
     
  7. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    44
    Has anyone had issues with svg assets looking poor / not anti-aliased on iOS devices?

    The assets look mint on Android, but on iOS they're pretty rough around the edges... My first thought was that it had something to do with the retina display, but it's hard to tell.
     
  8. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    131
    I am stuck at the same error, any ideas?
     
  9. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    39
    Has anyone an idea. I want my SVG sprites to use the SVG Importer/SolidColor/SolidColorDiffuseOpaque shader. I am setting this currently in the inspector on any sprite object and it works. But when I load the project again, this is always set to SVG Importer/SolidColor/SolidColorOpaque again. I am probably not setting this at the correct place, can anyone give me a pointer?
     
  10. JaimeAL

    JaimeAL

    Joined:
    Dec 4, 2015
    Posts:
    21
    Regarding this error, manually declaring what is missing seems to work so far. In the script SVGImporterSettings.cs:

    Code (CSharp):
    1.         public static SVGImporterSettings Get
    2.         {
    3.             get {
    4.                 if(_instance == null)
    5.                 {
    6.                     _instance = Resources.Load<SVGImporterSettings>("svgImporterSettings");
    7.                     if(_instance == null)
    8.                     {
    9.                         Debug.LogError("Cannot Load SVG Importer Settings! Please Move SVG Importer Settings in to Resource folder.");
    10.                         _instance = ScriptableObject.CreateInstance<SVGImporterSettings> ();
    11.                         _instance.defaultSVGFormat = SVGAssetFormat.Transparent;
    12.                         _instance.defaultUseGradients = SVGUseGradients.Never;
    13.                         _instance.defaultAntialiasing = true;
    14.                         _instance.defaultAntialiasingWidth = 2f;
    15.                         _instance.defaultMeshCompression = SVGMeshCompression.High;
    16.                         _instance.defaultVerticesPerMeter = 1000;
    17.                         _instance.defaultScale = 0.001f;
    18.                         _instance.defaultDepthOffset = 0.01f;
    19.                         _instance.defaultCompressDepth = true;
    20.                         _instance.defaultCustomPivotPoint = false;
    21.                         _instance.defaultPivotPoint = new Vector2 (0.5f,0.5f);
    22.                         _instance.defaultGenerateCollider = false;
    23.                         _instance.defaultKeepSVGFile = false;
    24.                         _instance.defaultUseLayers = false;
    25.                         _instance.defaultIgnoreSVGCanvas = true;
    26.                         _instance.defaultOptimizeMesh = true;
    27.                         _instance.defaultGenerateNormals = false;
    28.                         _instance.defaultGenerateTangents = false;
    29.                         //INVENTAO
    30.                         _instance.defaultSVGIcon = null;
    31.                         _instance.ignoreImportExceptions = true;
    32.                     }
    33.                 }
    34.  
    35.                 return _instance;
    36.             }
    37.         }
    If you ever have to use this, keep in mind to write down your on settings!
     
  11. JaimeAL

    JaimeAL

    Joined:
    Dec 4, 2015
    Posts:
    21
    Been having issues with antialising for months now, sometimes it is as random as that if you change the rotation or scale of an object it will stop processing Antialising properly.

    Sometimes even it will go bananas and make a blurry mess when scaling down.

    This happens both in iOS and Android, mobile and tablet. We have to go SVG per SVG checking their quality settings and such to try to work-around it. So far we manage, but it'd be great to have antialising working back again, as much as I love pixel art I do not think it goes well with SVG.
     
    shaneparsons likes this.
  12. tacoilluminati

    tacoilluminati

    Joined:
    Oct 30, 2015
    Posts:
    6
    Hey y'all, noticed that the SVG Editor for setting pivots / sliced corners editor window broke in 5.6, you'll need to change some code to fix it.

    Go to SVGEditorHandles.cs and change this line:

    Code (CSharp):
    1. typeof(HandleUtility).GetMethod("ApplyWireMaterial", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null);
    To:

    Code (CSharp):
    1. //top of file
    2. using System.Linq;
    3.  
    4. //fix for above code
    5. typeof(HandleUtility).GetMethods(BindingFlags.Static | BindingFlags.NonPublic)
    6.     .First(m => m.Name == "ApplyWireMaterial" && m.GetParameters().Length == 0)
    7.     .Invoke(null, null);
    (Or something like it). Not used to reflection, so I'm not sure if there's a better way to handle an AmbiguousMatchException. Haven't tested outside of Unity 5.6 but theoretically would work on earlier versions of Unity.
     
  13. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    Doesn't seem to work at all with Unity 2017.1.0b1.
     
  14. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    Ugh, this is a real shame. This asset is amazing and I feel for the developer, I hope he makes a recovery soon. For now I've had to switch back to using sprites for my project as can't rely on using a 3rd party asset that isn't supported anymore :(
     
  15. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    Maybe someone could compile a Google Doc of all the changes/fixes that are needed from the currently released 1.1.3 version of this asset to help the developer out, save time and hopefully get an update? That way everything is on one page and you don't have to dig through pages of forum posts to find fixes.
     
  16. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    So I reached out to Jaroslav on Twitter, he looks busy working on some vr projects at the moment. He said he is open to the idea of selling his asset to another developer, so that they could keep up the development:

    https://twitter.com/jaroslavstehlik/status/856837157494894592

    Anyone interested? Such a great asset, shame to see it go away.
     
  17. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Maybe Unity team ? ;-)
     
  18. m7g2

    m7g2

    Joined:
    Sep 23, 2012
    Posts:
    4
    Pulas, tacoilluminati and leenk like this.
  19. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there folks, Alive again.
    Could I help you with fixing the bugs?
     
  20. skillbow

    skillbow

    Joined:
    Dec 2, 2014
    Posts:
    7
    Great to have you back! I think the most important bugs are with Unity 5.6 compatibility (see above) and from a personal point of view would be great if there could be some draw call batching, as I'm getting a lot of draw calls - not sure it's possible but would be great.
     
  21. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Draw Call batching is a problem,

    because vector graphics contains a lot of triangles it is highly not recommended
    as it can really slow down the CPU.
    I would recommend using static batching as the main optimization for this case.
    https://docs.unity3d.com/ScriptReference/StaticBatchingUtility.Combine.html

    you can use at runtime this command which has a root.
    That means that root can move but children cannot which can save a lot of draw calls.
     
  22. skillbow

    skillbow

    Joined:
    Dec 2, 2014
    Posts:
    7
    Thanks very much. I'll give this a go. It looks like it should reduce the calls.
     
  23. JaimeAL

    JaimeAL

    Joined:
    Dec 4, 2015
    Posts:
    21
    Hello, just to bump it

    I am having issues with Antialising turning off in assets that go through some kind of transformation, some SVGs apply Antialising just fine but when they get some rotation or scaling going on the antialising just disappears and goes back to being pixely, going back to the transform in which Antialising worked brings it back. Its really confusing

    I explained further another antialising issue in a previous post in page 20: https://forum.unity3d.com/threads/s...upported-released.323618/page-20#post-2917731
    and in this very same page a quick fix to that issue about undeclared stuff that broke SVGs in some Android versions
     
    shaneparsons likes this.
  24. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Could you please send me an example?
    Thank you.
     
  25. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    overthere, shaneparsons and jGate99 like this.
  26. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    I was quite disappointed when this plugin seems to have no future. Because there is not even a single alterantive to it. So losing it was not easy. Now your new message changes everything.

    I fully support you and your decision to focus on latest unity versions. Its Better than having a latest version supported only plugin THAN not having at all.

    Thank you for coming back :)
     
    shaneparsons likes this.
  27. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    I thank you for understanding my situation.
    I feel ashamed a lot by these circumstances because I fell in these problems by myself.
     
  28. danilom1111

    danilom1111

    Joined:
    Mar 11, 2016
    Posts:
    3
    Hey @Jaroslav-Stehlik , we are glad to see you back :) i support your decision to work on new unity versions :) one quick question... my company is making coloring apps and we would like to fill areas of an image with gradients, but i am unable to change solid color fill to gradient. Additionally i see that there is support for FILL_TYPE.TEXTURE but i am not sure how to use these options. Any suggestion would make my life so much easier, thank you. And welcome back!
     
    Jaroslav-Stehlik likes this.
  29. rarebyte

    rarebyte

    Joined:
    Sep 26, 2015
    Posts:
    11
    I vote for 5.6+ support at the cost of older versions
     
    shaneparsons likes this.
  30. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    I was wondering, is it possible to bake a light map for SVG assets ?

    Thanks
     
  31. tacoilluminati

    tacoilluminati

    Joined:
    Oct 30, 2015
    Posts:
    6
    Jaroslav-Stehlik, absolutely make sure you take care of yourself! We totally understand. As for prioritizing versions, I think Unity 5.6+ (or simply just the most recent release of Unity at any given point) is totally acceptable. Thanks for all your hard work!
     
    overthere, shaneparsons and skillbow like this.
  32. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi guys,

    In my current project I suddenly have a new error :

    Some assets have their SGRenderer and Mesh Renderer deactivated and no materials at all. Even if I re-activate and re-assign material, as soon as I hit the Play button scripts are deactivated and materials removed. I tried to delete and re-import the plugin but the error remains.

    Any idea why ?

    Thanks
     
  33. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Ok, just for let you know, by activating normals and tangents on all SVGAssets the error is gone. Not sure why, but at least is fixed.
     
  34. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thank you for your report.
    I never baked light in SVG Importer, so that is quite interesting behavior!
     
  35. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thank you! I will submit an update for 5.6 soon!
     
    shaneparsons likes this.
  36. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    I have an issue with layer and sorting order. In my current projet I have for example 3 SVGs which have the same z position value, the same layer but different sorting order. But layer and sorting order seems to not be used correctly and the SVG that should be in front of the other is behind. Even if I set a very big sorting order and set the most front layer nothing change. The only thing that made this asset to be displayed in front of the other is tho change it's z position value.

    Is that normal ? How can I fix that ?

    Thanks
     
  37. ckromero_amplify

    ckromero_amplify

    Joined:
    Feb 10, 2017
    Posts:
    1
    hi -
    This is a really useful plugin and I really appreciate your efforts in putting together such high quality work, I hope you're able to continue working on it and I'm looking forward to checking out your VR, I know how demanding such projects can be!
    I just went to install SVG Importer into a project in Unity 5.6 and I'm seeing a lot of errors related to the Editor namespace, is that part of what you're working on for the 5.6 update? I just want to make sure this isn't being caused by other issues.
    Thank you,
    Christopher
     
  38. Francknight

    Francknight

    Joined:
    Apr 25, 2016
    Posts:
    2
    When I export to svg as indicated in Svg Importer's documentation, if the misbehavior of the object is small by importing into unity the result is bad. Why is this happening? Thanks in advance. Frank
    result_unity.jpg export_ai.jpg
     
  39. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Hi, I'm interested in this tool but the lack of updates on the last several months makes me worried. Any updates planned?

    [EDIT]
    I just read the rest of the thread and found out about the developer situation. Wish you all the best and hope you find the strength to get back in full health. Best regards!
     
    Last edited: May 20, 2017
    Jaroslav-Stehlik likes this.
  40. Francknight

    Francknight

    Joined:
    Apr 25, 2016
    Posts:
    2
  41. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Yes, I have already a version which does not produce any error, I have to just let testers to try it before submitting on asset store. Want to become a tester? Send me your invoice on my email with your request.
     
  42. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hello,

    SVG Importer tries to optimize your graphics as well as possible. The quality of the result is dependent on the size of the vector graphics in pixels. If you want to increase the quality of the tesselation just increase the quality number on the asset by large numbers. Hope this helps.
     
  43. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    Would it be possible for someone who has already applied patches to share patched shader directly ? Would be very helpful because shader errors make the project unable to build correctly using Unity Cloud.

    Thanks
     
  44. THEckromero

    THEckromero

    Joined:
    Jan 24, 2017
    Posts:
    1
    Jaroslav -
    Very good, posted invoice info on the form on your website, thanks!
     
  45. m7g2

    m7g2

    Joined:
    Sep 23, 2012
    Posts:
    4
    https://gist.github.com/mejje/9b0dcb853f23cb2e298df84d75bfae41

    Jaroslav let me know if I'm violating something here and I'll remove it!
     
    Jaroslav-Stehlik likes this.
  46. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Thanks !
     
  47. Blue-Candle-Games

    Blue-Candle-Games

    Joined:
    Jun 17, 2015
    Posts:
    4
    Any ETA on the new patch? Looking forward to buying the product when it releases.
     
  48. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
  49. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    I just submitted the new version on Asset Store,
    I hope it will propagate fast and that it will solve the most critical issues.

    Other issues will be solved one by one in the next time.
    Thank you for your support.
    I am a little bit slow after my medical treatment and I do understand
    things a little bit slower, so I will probably ask you stupid questions
    during debugging. But I want to fix the issues.

    Have a great day!
     
    shaneparsons, Naxite, jGate99 and 3 others like this.
  50. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Great !

    Could you enumerate what have changed/ been fixed ?

    Thanks
     
    shaneparsons likes this.