Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    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. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thanks for that will take a look at it.
     
  2. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    Thanks for your reply,
    waiting desperately
     
  3. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    256
    I've not tried it yet, but there is this plugin https://creative.adobe.com/addons/products/2955
     
    v2-Ton-Studios likes this.
  4. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    11
    Hi,
    I've some problems exporting to Playstation 4, in which SVG assets are not displayed at all.
    This also happens building the demo provided with the plugin.
    What could be the problem?

    Note: Exporting to Xbox One works like a charm.

    Thanks
     
  5. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    I'm having an issue where my sorting layers are mixed up on the builds (ios & android) of my game. I've looked everywhere and tried just about everything trying to resolve this, but haven't had any luck... which gives me the suspicion it's something to do with SVG Importer.

    Everything works perfectly in the editor, only the build has issues.

    Has anyone had this problem before / does anyone know what might be causing it?
     
    Last edited: Sep 28, 2016
  6. Aguillen

    Aguillen

    Joined:
    Sep 18, 2013
    Posts:
    1
    I'm using Unity 5.4 and I can only import the simplest SVGs, import fails everytime I try to import more complex graphics.

    Has anyone else had the problem where the SVG is imported but graphic is invisible?
     
  7. jasonMcintosh

    jasonMcintosh

    Joined:
    Jul 4, 2012
    Posts:
    71
    I don't have an answer for the problem, but I can say that I use a fairly complex setup with about 8 layers in my Android game and haven't had any issues with it. I'm using Unity 5.3.

    Edit: Also, I'm using the "Unity Sorter" so my experience might not apply if you're using the SVG override Sorter.
     
    Last edited: Sep 13, 2016
  8. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    Thanks for the feedback.

    My setup is pretty basic. By the sounds of it, a difference between mine and yours being I have 3 separate containers (empty game objects) – one were I instantiate `background` objects, one for `midground` objects and one for `foreground` objects. The sorting within the containers doesn't matter to me, it's just the containers themselves that are being mixed up.

    This same case with sprites should work as intended, which is the reason I'm thinking it has something to do with SVGs.

    If anyone else has any input, I'd much appreciate it!

    EDIT

    I think I've narrowed down the issue to the Mesh Renderer not inheriting the sorting layer correctly, as manually setting it seems to temporarily fix the issue.

    Any Ideas @Jaroslav-Stehlik?
     
    Last edited: Sep 15, 2016
  9. atti

    atti

    Joined:
    Feb 22, 2011
    Posts:
    84
    Hi Jaroslav,

    I got SVG Importer recently and love it. Only concern I have:
    Apparently it depends on System.Xml (or at least it prevents the compiler from stripping it). For WebGL this results in a build size increase by around 1.5 MB. A huge bummer for me.

    Is there an easy way to avoid this? Have you considered optimizing for WebGL build size (before)?

    Thanks!
     
  10. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    I am finding that shapes randomly come out completely white when in play mode or during builds.

    Also I am finding that gradients are very dithered; not at all smooth like they are in the original SVG file.

    What is causing these two problems?
     
  11. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    I suspect this is required for the runtime parsing of .svg files; it would be good if there was a way to exclude runtime .svg parsing when this functionality is not required. In my projects the .svg import only needs to happen at design time; then at runtime SVG Importer just needs to render from it's .asset file. So +1 for a way to exclude this dependency in final builds.
     
  12. jasonMcintosh

    jasonMcintosh

    Joined:
    Jul 4, 2012
    Posts:
    71
    I think that's a bug in the gradient rendering which is fixed in the upcoming version.
     
  13. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    Awesome, thanks for the heads up. I hope that the update comes out soon otherwise I will have to find an alternative for my project; at least for the short-term.
     
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    Any update on it?
     
  15. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
  16. mgmhunt

    mgmhunt

    Joined:
    Apr 1, 2013
    Posts:
    52
    Build works locally for Windows 64-bit, but using Unity Cloud Build I get a fail because of these two errors.

    94582: [Unity] Shader error in 'SVG Importer/Standard SVG': Program 'fragForwardBase_SVG', error X4506: ps_4_0_level_9_1 input limit (8) exceeded, shader uses 9 inputs. (on d3d11_9x)

    94588: [Unity] Shader error in 'SVG Importer/Standard SVG Specular': Program 'fragForwardBase_SVG', error X4506: ps_4_0_level_9_1 input limit (8) exceeded, shader uses 9 inputs. (on d3d11_9x)

    [Unity] Player export failed. Reason: 2 errors

    98587: ! build of 'default-windows-desktop-64-bit' failed. compile failed

    Can you replicate?
     
    TeamZero likes this.
  17. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    I too am getting these errors in builds.
     
    TeamZero likes this.
  18. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    Hmmm, when I create a prefab that contains an SVG Renderer; and that prefab gets instantiated at runtime; it looks fine the first time I hit the play mode button but is bright magenta the second/third/fourth/etc time that I press the play mode button. The only solution seems to be to reload Unity... and then the cycle repeats from the start. Works fine the first time I hit play mode but all of the SVG Renderer's are bright magenta.

    When I select the SVG Renderer objects and examine the inspector I see that there are no materials assigned to the mesh renderer when the magenta issue occurs.
     
  19. Deathfate

    Deathfate

    Joined:
    Sep 10, 2012
    Posts:
    46
    That normally happens in the release version, you need the updated version that Jaroslav sends you by email, that version fixes gradients and missing materials
     
  20. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    I'm not sure how you define complex. I'm definitely seeing errors every time I import an SVG and also when I drag it into a scene. And, like you note, some SVGs simply won't import. However most do. For what I can see this doesn't seem to be dependent on complexity. See image linked below -- of the two the one that works seems to be more complex :|.

    https://www.dropbox.com/s/wzk79j8orssc8sx/SVGImporterOkayFail.PNG?dl=0

    I'm also using Unity 5.4.0

    These are the errors I'm getting for the failed asset. Any help is appreciated.


    SVG Document Exception: Unknown char: .
    UnityEngine.Debug:LogError(Object, Object)
    SVGImporter.SVGAssetImport:StartProcess(SVGAsset) (at Assets/SVG Importer/Plugins/Core/SVGAssetImport.cs:97)
    SVGImporter.SVGAsset:_editor_LoadSVG() (at Assets/SVG Importer/Plugins/Core/SVGAsset.cs:1410)
    SVGImporter.SVGAsset:_editor_ApplyChanges(Boolean) (at Assets/SVG Importer/Plugins/Core/SVGAsset.cs:1253)
    System.Reflection.MethodBase:Invoke(Object, Object[])
    SVGImporter.SVGPostprocessor:ImportVGAsset(String) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:210)
    SVGImporter.SVGPostprocessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:143)
    UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

    SVG Document is corrupted! Assets/Terrain/ch2_Z3_GroundCeiling.asset
    UnityEngine.Debug:LogError(Object, Object)
    SVGImporter.SVGAssetImport:StartProcess(SVGAsset) (at Assets/SVG Importer/Plugins/Core/SVGAssetImport.cs:103)
    SVGImporter.SVGAsset:_editor_LoadSVG() (at Assets/SVG Importer/Plugins/Core/SVGAsset.cs:1410)
    SVGImporter.SVGAsset:_editor_ApplyChanges(Boolean) (at Assets/SVG Importer/Plugins/Core/SVGAsset.cs:1253)
    System.Reflection.MethodBase:Invoke(Object, Object[])
    SVGImporter.SVGPostprocessor:ImportVGAsset(String) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:210)
    SVGImporter.SVGPostprocessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:143)
    UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

    SVGAsset: ch2_Z3_GroundCeiling
    errors: Syntax.
    path: Assets/Terrain/ch2_Z3_GroundCeiling.asset

    UnityEngine.Debug:LogError(Object, Object)
    SVGImporter.SVGAsset:_editor_ApplyChanges(Boolean) (at Assets/SVG Importer/Plugins/Core/SVGAsset.cs:1301)
    System.Reflection.MethodBase:Invoke(Object, Object[])
    SVGImporter.SVGPostprocessor:ImportVGAsset(String) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:210)
    SVGImporter.SVGPostprocessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:143)
    UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])
     
  21. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    Found other issues...

    - Lighting does not seem to work. I've generated normals, reimported. Created a Sprites/Diffuse material. And, assigned it to the imported SVG. When assigning the Sprites/Diffuse material the SVG disappears. It's not dark or moved. It no longer renders anything.

    - Gradients also seem to be broken. Despite setting 'Gradients = Always' on the importer the render as a fully opaque fill.

    Are these known issues? As always help is appreciated. Again, I'm using Unity 5.4.0

    (Uninstalling the Illustrator 2015 -- nothing but headaches with it... Installing 2014, see if that fixes anything.)

    EDIT: I've downgraded to Illustrator CC 2014. And reexported all SVGs using the approach and exact settings outlined in the video below. Still no luck. When I give things a Sprites / Diffuse shader they all disappear. And, as before gradients are rendering as solid fills. Help...!?!? :)

     
    Last edited: Sep 21, 2016
  22. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    SVG Importer has troubles parsing a great deal of svgs from Illustrator, more specifically the decimal numbers that tend to make up the svgs. It used to be only the vanilla 'save as' option would work, but now I believe there's even issues with that.

    I use this plugin for Illustrator, which works flawlessly every time. Just make sure your layers are named with .svg at the end, and make sure the layers don't contain any symbols.
     
    Last edited: Sep 21, 2016
    davecdempsey likes this.
  23. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    Thanks Shane, I'll give that a go. Should I assume that will fix the lighting and gradient issues I'm having as well. Or, is that something distinct?

    EDIT: Hrm I get an error from the script when trying to execute.


    Error 60: Not well-formed (invalid token).
    Line: 593
    -> <td id="LC34" class="blob-code blob-code-inner js-file-line"><span class="pl-k">try</span> {</td>


    ... think it might be time to give up on this, get a refund, and stick with good ol' sprites :|.
     
    Last edited: Sep 21, 2016
  24. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    I haven't really touched lighting or gradients at all so it's hard to say. If the svgs are corrupted though I could see how it could lead to issues like that.

    I'm unfamiliar with that error as well. The only errors I ever had were graphics containing symbols not showing up on the output. Is there anything unusual about the graphic you're trying to export? P.S. I'm also using the latest version of Illustrator, but I've had the plugin working on previous versions as well.

    EDIT: Your issue sounds like it could be along the lines of this one.
     
    Last edited: Sep 21, 2016
  25. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    What a bizarre error... but yep, it was the download one. With that lighting and gradients also work. Man, Adobe really needs to get their act together.

    Thanks so much for the help Shane, very appreciated!

    EDIT: Shane, have you found a way to get the script to remember the last save path?

    EDIT: Womp womp... lighting doesn't work. If I assign a Sprites/Diffuse to a single SVG it's fine, but if I assign it to a second, the other "SVGs" in the scene disappear. So strange. Okay, refund time... wasted 2 days with this now. I'm sure it will work for others, and I don't mean to disparage the work the folks behind it have done, but for me it's just not working.
     
    Last edited: Sep 21, 2016
  26. DoomerDGR8

    DoomerDGR8

    Joined:
    May 15, 2015
    Posts:
    12
    Hi!

    I'm wondering if it is possible to work with SVG assets in the form of sheet (like spritesheet)? Kenny has supplied with one SVG with multiple equal sized assets in single file. Can this tool manage slicing?
     
  27. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    904
    Can export this style?
     

    Attached Files:

    • grid.jpg
      grid.jpg
      File size:
      70.7 KB
      Views:
      371
  28. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    949
    I just updated to 1.1.3 but am now seeing the following error in the console window:
    I don't know whether this is related to the above; but some of my SVG renderer's are showing lots of black triangles which appear to be Z-fighting with the desirable SVG geometry.
     
  29. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    183
    Friendly bump to see if there are any thots on the issues noted above. Cheers!
     
  30. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    Glad that fixed it... it's a shame about the other problems though.

    I always assumed the file path was determined based on where the file was located but I could be wrong. I generally just do a mass export all at once.

    As I said before, I personally have never touched lighting so someone else will have to help you with that one. You may want to contact the developer personally as well, as he doesn't seem to get back to the forums too frequently.
     
    Last edited: Sep 26, 2016
  31. shaneparsons

    shaneparsons

    Joined:
    May 5, 2015
    Posts:
    41
    I don't think it can handle the slicing, but if they are already sliced as separate files the SVG Frame Animator is likely what you're looking for.
     
    Last edited: Sep 26, 2016
  32. appart_si

    appart_si

    Joined:
    Jun 14, 2016
    Posts:
    1
    Hello! I have a problem. On high end devices with high resolution (Samsung S6 - S7), i get wierd svg rendering. It seems that some shadows or the components of svg get offset rendered and get wierd lines. Here are two examples:
    On the left are the examples from correct svg rendering on low res. devices. On the right side there is the problematic render on S6 and S7. What could be the problem?

    Thanx in advice!
     
    numberkruncher likes this.
  33. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    920
    @Jaroslav-Stehlik
    Still Waiting
     
  34. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thank you for the report, this is wery strange behaviour
     
  35. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hello, this could be solved with atlas offsetting.
    I have to implement this.
    It is caused because of rounding errors caused by mobile GPUs
    as they do not have perfect single precision as CPU does,
    by creating borders around gradients this issues should be resolved.
     
  36. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Could you please send me a screenshot and the version of Unity and the project? thank you!
     
  37. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    Since Unity 5.4 or something like that, when playing my game from the editor some SVG assets would appear pink - except the first time. This is only an editor issue, when the game is deployed there is no problem. So it's just a visual issue but it's really annoying.

    Any idea why ?

    Thanks
     
  38. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    Hi,
    I have a stroke with a linear gradient in Illustrator 2015.3, the gradient is applied along the stroke, which when expanded creates a gradient mesh. Does anyone know if this is supported or a work around as my stroke gradients seem to be ignored by SVG importer.
     
    Last edited: Oct 4, 2016
  39. jasonMcintosh

    jasonMcintosh

    Joined:
    Jul 4, 2012
    Posts:
    71
    That bug was fixed in the latest version, which you can get from the asset store.
     
  40. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    Not sure if it's related but I was receiving shader errors after 1.1.3 update. I believe there's some issues with line endings in the shaders.
    Some of my SVGs were showing pink because of shader errors.

    I was receiving the same "cannot include SVGImporterGradientCG.cginc" errors with GradientColorAlphaBlendedAntialiased.shader & UI.Shader

    I opened both those files, found the include line and changed it to something wrong, saved it, changed it back saved again and it worked.
     
  41. Deathfate

    Deathfate

    Joined:
    Sep 10, 2012
    Posts:
    46
    I think thats an Unity 5.4 issue, just right click the svg importer folder and click on reimport
     
  42. pixxelbob

    pixxelbob

    Joined:
    Aug 26, 2014
    Posts:
    111
    yeh I tried that, that's what led me to believe it's line endings because Unity reports tons of warnings when importing svg importer

    "There are inconsistent line endings, This might lead to incorrect line numbers in stacktraces and compiler errors."

    I have manually resolved all the line ending issues in all the shaders & scripts and it seems OK now, maybe the author could fix in the next patch release.
     
  43. chandler55

    chandler55

    Joined:
    Jun 8, 2010
    Posts:
    16
    hi I'm a little confused on how to prevent my sliced svgrenderer's from being culled. the mesh's bounds dont match the full sliced image, its a small square that matches the original svg unstretched, so whenever that bounds is off camera the whole sliced image disappears
     
    Last edited: Oct 9, 2016
  44. martinpi

    martinpi

    Joined:
    Jan 26, 2013
    Posts:
    1
    Hi, in 5.4 (OSX) with build 1.1.3, I'm getting the following error when importing the shaders:

    Shader error in 'SVG Importer/Standard SVG': invalid subscript 'posWorld' 'FragmentSetup': no matching 5 parameter function at Assets/SVG Importer/Plugins/Shaders/Standard/UnitySVG.cginc(118) (on glcore)

    Compiling Vertex program with DIRECTIONAL LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF _ALPHABLEND_ON
    Platform defines: UNITY_NO_SCREENSPACE_SHADOWS UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF2 SHADER_API_DESKTOP UNITY_HARDWARE_TIER3
    The resulting game still works on the target device (iOS) but the view in the editor has some severe problems, leading to randomly displaced vertices (especially when objects are moving) and a completely blank view now and then (restarting Unity fixes that). I've re-downloaded and re-imported several times. The line in question has only the FRAGMENT_SETUP(s) macro in it.
     
    seidensj likes this.
  45. ReaktorDave

    ReaktorDave

    Joined:
    May 8, 2014
    Posts:
    111
    Does this asset support the upcoming Unity 5.5?
     
  46. slake_it

    slake_it

    Joined:
    Aug 2, 2015
    Posts:
    75
    Hello,
    we are very happy with svg importer, however,
    regarding performance, i noticed that every svg imported mesh causes a draw call
    - should we use sprites for the elements that have many instances on screen ?
    - is draw calls a real issue or is it really light weight if we have a simple mesh ?

    Thanks
     
  47. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Is there any way to prevent SVGAtlas.Update() getting started automatically? It causes GC allocations and I would like to disable it on our server app.
     
  48. Djungalio

    Djungalio

    Joined:
    Feb 5, 2016
    Posts:
    5
    Hello,

    I bought the package and imported it straight forward into my project and after that my app wont build. I am getting the following error.

    Assets\SVG Importer\Plugins\Core\Implementation\XML Parser\SmallXmlParser.cs(106,26): error CS0117: 'char' does not contain a definition for 'GetUnicodeCategory'
    Assets\SVG Importer\Plugins\Triangle\IO\FileReader.cs(501,59): error CS1503: Argument 1: cannot convert from 'string' to 'System.IO.Stream'

    When I create new project and import the package there its ok but i want to use it in already existing project.

    Any advice on how to fix the problem?

    Regards,
    G.G.
     
  49. Deathfate

    Deathfate

    Joined:
    Sep 10, 2012
    Posts:
    46
    change your platform, you are using webgl, use android, pc, or ios
     
  50. Knertified

    Knertified

    Joined:
    Jul 3, 2012
    Posts:
    31
    Hi, is there a way to get access to the pixel data of the SVGImage object? I tried attaching a RenderTexture to the mesh render to take a snapshot and was unsuccessful. Basically I want to get an array of pixels. Love the plugin. Thanks!