Search Unity

Vector Graphics Preview Package

Discussion in '2D Experimental Preview' started by rustum, May 4, 2018.

  1. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    This refers to the material's color (not the renderer's color). The material's color wasn't applied in the VectorGradient shader.

    This can be used as a workaround to tint the SVG sprites when GPU instancing is not an option. You can create an extra material, assign it to the sprite, and change the material's color to tint it. This is not the most efficient way to do it, but can be used as a workaround.
     
    nickfourtimes likes this.
  2. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    154
    Ah, right, so we can have an SVG sprite with a gradient, mask it, and also change its colour. That's good, thanks!
     
  3. mikewarren

    mikewarren

    Joined:
    Apr 21, 2014
    Posts:
    77
    Any idea when SVG text might be supported (best guess)? I'm looking for a way to (dynamically) render SVG files in Unity but they have text that's important.

    Otherwise, can anyone recommend an SVG renderer that works with UWP / .Net Core (for a Hololens)? I need to turn an SVG into a Texture2D at run time.
     
  4. Shiraga

    Shiraga

    Joined:
    Dec 21, 2016
    Posts:
    3
    Do you have any idea when Vector Graphics will be out of preview at this time? If so I'd be interested in knowing since I'd really like to use it in our next release.
     
  5. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Text is a massive topic and most of the text features are supported by TextMeshPro, so ideally we would want to integrate with that. I cannot tell when/how this will happen though.

    If that makes sense for your project, you could create textless SVG sprites and add TextMeshPro meshes over them, but I understand this requires some manual work.
     
  6. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    I cannot tell. The SVG package is still in preview, but some users are already shipping games with it. Even though the team efforts has be diverted on a more urgent project, we try to fix serious issues in a timely manner. So if the package solves a problem for you, I think it's safe to use it. You could even embed the package in your project to make sure it will always be available "as is".
     
    Last edited: Apr 12, 2019
  7. mikewarren

    mikewarren

    Joined:
    Apr 21, 2014
    Posts:
    77
    Ok. I appreciate your suggestion. It's probably beyond me.
     
  8. michaeleconomy

    michaeleconomy

    Joined:
    Aug 28, 2018
    Posts:
    20

    Will we be able to use the SpriteRenderer color in future releases? This would be great.
     
  9. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    91
    I'm trying to take a Sprite object (from an imported SVG) and access the Shape objects that it contains. By digging through VectorScene.cs, it seems like the Scene class (and its SceneNode objects) will be a good way of doing that. However, I can't seem to figure out how to start with a Sprite object and get at its Scene. Can anyone point me in the right direction?
     
  10. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Agreed. Note that the SpriteRenderer color works fine when using GPU instanced materials (which is the default). We made an early attempt for platforms without GPU instancing support, but this inflated the vertex buffer quite a bit, and we wanted to avoid this. We'll have to come back to it later.
     
  11. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    The SVG sprite object will contain a tessellated version of the SVG vector data, so you won't be able to get back the Scene object from it.

    The Scene object is use for the vector graphics API, which you can then tessellate an turn into meshes or sprites. The SVG importer also uses the Scene object as an intermediate representation. So the flow of data is: SVG file -> Scene object -> Sprite or Mesh.

    If you keep a textual representation of the SVG file somewere, you can load it at runtime into a Scene object. There's an example here:
    https://github.com/Unity-Technologi...b/master/Assets/RuntimeDemo/SVGRuntimeLoad.cs
     
  12. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    91
    Thanks for the info! My real goal here is to be able to change the fill color of shapes, or more specifically, to be able to say "change all color X fills in the SVG into color Y." Is there no way to do this at runtime without essentially reimporting the SVG?
     
  13. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    You don't have to reimport it every time you want to change the fill, you can import it once, keep the Scene object aside and modify it at will before tessellation. Here's an example:

    Code (CSharp):
    1. var sceneInfo = SVGParser.ImportSVG(new StreamReader(svgPath));
    2. var shape = sceneInfo.NodeIDs["ShapeID"].Shapes[0];
    3. var fill = shape.Fill as SolidFill;
    4. fill.Color = Color.red;
    5. // ...
    6. var geoms = VectorUtils.TessellateScene(sceneInfo.Scene, tessOptions);
    7. var sprite = VectorUtils.BuildSprite(geoms, 100.0f, VectorUtils.Alignment.Center, Vector2.zero, 128, true);
    8.  
    Here I change the fill color of the shape identified by "ShapeID" in the SVG file (the NodeIDs dictionary contains a mapping between SVG shapes with the "id" attribute and the resulting SceneNode object). Otherwise, the sceneInfo.Scene will contain the full node/shapes hierarchy.
     
  14. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    183
    We are taking a look on the mask interaction with instancing. As a workaround please use this shaders:
    https://www.dropbox.com/s/mzpct8hw6aq7g94/Sprites-Instancing-Default-VisibleInsideMask.shader?dl=0
    https://www.dropbox.com/s/0d6azbepwbixgud/Sprites-Instancing-Default-VisibleOutsideMask.shader?dl=0
     
    nickfourtimes likes this.
  15. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    91
    Thanks! That should help get me started.
     
  16. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    @mcoted3d @Sergi_Valls I am using the Vector package extensively for an iOS game.

    It's amazing, well done guys.

    I only have three pain points:

    1. SVG import doesn't read artboard size of the SVG. Is this something bad I am doing in illustrator?
    2. When using SVG in canvas, any SVGimage will be 100px 100px. Would be nice if it came in at the pixel size the SVG is, or failing that if we could get a pixel size in the inspector for the SVG, or a Preserve Ratio clamp for the SVG image / Set Native Size button. Currently I need to go in to Illustrator for each SVG and copy out the native size x y so the SVGs display at their original aspect ratio in Unity.
    3. Will antialiasing be coming to Canvas SVGs?

    (something like this for #2)

    svgimage.png
     
    Last edited: Apr 20, 2019
  17. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Hi! There are two things you should try:
    - Check the "Preserve Viewport" option from the SVG inspector. This will make the generated sprite use the viewport size of the source SVG file.
    - When exporting from Illustrator, uncheck the "Responsive" option. This option output a "viewBox" attribute in the <svg> tag which cause the SVG sprite to resize to a 100x100 "window size". We will try to improve this in the future.

    For a Canvas UI, you can try to set the render mode to "Camera Space" and enable antialiasing for your project (in Project Settings > Quality). If this is not an option for you, your options will be more limited (you can import your SVG assets as antialiased textured sprites instead, which comes with some drawbacks as well).

    Hope this helps!
     
  18. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    475
    Cool! Thanks for the advice & pointers! I shall try this out
     
  19. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Hello,

    I found a bug when using the "Rotate" property on the SVG Transform (XML). If you use it, when you import the SVG to unity it translates the image in a wrong way.
    Here are screenshots for example:

    How the image looks on Inkscape and on Google Chrome --> https://i.imgur.com/Nhl7AgJ.png
    How the image looks on Unity when imported (I zoomed out to catch all the pieces) --> https://i.imgur.com/4GrHpSZ.png
    How the image looks on Unity when I rotate the whole image by 90° on Inkscape and re-import --> https://i.imgur.com/CZzlG5n.png

    Basically, any image that has something like: transform="rotate(90,626.43471,-1469.3046)"
    it will be sent to the extreme corners based on the "rotate" number instead of just rotating the image and keeping it on the correct transform position.

    Sending the SVG as attachment.

    Is it a previously known/intended behaviour? Any tips? @mcoted3d
     

    Attached Files:

  20. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    It's definitely not intended, you basically found a bug on how we apply the rotation center (we basically inverted the translation component of the transform matrix). I'll try to push a fix soon. If you want to patch the package yourself in the meantime, it's a simple change:

    Code (CSharp):
    1. diff --git a/Runtime/SVGParser.cs b/Runtime/SVGParser.cs
    2. index 8dfe6f9..86f78ce 100644
    3. --- a/Runtime/SVGParser.cs
    4. +++ b/Runtime/SVGParser.cs
    5. @@ -2733,7 +2733,7 @@ namespace Unity.VectorGraphics
    6.                          cx = NextFloat();
    7.                          cy = NextFloat();
    8.                      }
    9. -                    transform *= Matrix2D.Translate(new Vector2(-cx, -cy)) * Matrix2D.RotateLH(-a) * Matrix2D.Translate(new Vector2(cx, cy));
    10. +                    transform *= Matrix2D.Translate(new Vector2(cx, cy)) * Matrix2D.RotateLH(-a) * Matrix2D.Translate(new Vector2(-cx, -cy));
    11.                  }
    12.                  else if ((trasformCommand == "skewX") || (trasformCommand == "skewY"))
    13.                  {
     
    Edan-Smith likes this.
  21. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Hey, I just tested your solution and it worked perfectly here.

    Thank you for the quick reply and for the temporary fix snippet :D
     
    mcoted3d likes this.
  22. lindsayjorgensen

    lindsayjorgensen

    Joined:
    Apr 15, 2019
    Posts:
    1
    I was working with an .svg as a sprite in a scene in Linear Colour space and the colour on the sprite is wrong.
    I can see proper results by changing the shader to be

    Code (CSharp):
    1.  #ifdef UNITY_COLORSPACE_GAMMA
    2.                     fixed4 color = IN.color*_RendererColor;
    3.                 #else
    4.                     fixed4((GammaToLinearSpace(IN.color.rgb*_RendererColor.rgb)), IN.color.a*_RendererColor.a);
    5.                 #endif
    6.  
    7.                 OUT.color = color * _Color;
    where previously _RendererColour wasn't being adjusted
     
  23. ryanslikesocool

    ryanslikesocool

    Joined:
    Jul 31, 2016
    Posts:
    4
    I'm absolutely in love with this tool. It's made my current project much easier. I no longer have to model objects since I can just convert an SVG to a mesh and extrude the mesh based on what color that part of the SVG is. One little thing that'd be great to see is complex gradients, like ones that follow a path (plus the ability to sample the gradient along the path), if that's even possible. Again, thank you for this great tool.
     
    Last edited: Apr 28, 2019
    mcoted3d likes this.
  24. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Thanks for reporting (and fixing!) this issue, we will add this fix in the next version of the package!
     
  25. DorInception

    DorInception

    Joined:
    Jun 25, 2017
    Posts:
    8
    Hey,
    We are having issue with SVGImage on some mobile devices.
    This is only on Android and mostly Galaxy.
    In the attached image you can see at the top how it looks in editor (and other devices that do not have this problem)
    and at the bottom how it looks on the device (Galaxy S8 in this case)

    Also attached, is the SVG file (as a text file).
    Thanks
     

    Attached Files:

  26. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    It seems that some Android devices aren't happy with the way the shader handles gradients. We're having a look.
     
  27. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Isn't this action the same as simply exporting a SVG as PNG and using it? If not, did he do it at run-time or it was a pre-settings that he did configure?

    Is there any tips on how I could properly compare performance between SVGs x PNGs? (look for specific fields on profiler?)

    Is there any "quick maths" to compare SVG(AA x2) vs PNG(no AA) performance? like... 4000 Vertices on a SVG with basic colors = equivalent to 512kb PNG, 16000 Vertices on SVG with basic colors = equivalent to 2mb PNG... etc?

    I started migrating all my game from PNG to SVG because on the "Tiger Vector Graphics" video it said it would most likely increase performance + reduce final build size... But since we are kinda forced to use at least 2x AA when with PNG we wouldn't... I'm a bit confused right now... (I target low-end devices on WebGL as well)

    I am starting to wonder why people are choosing SVGs over PNGs...
    Final Build Size?
    Infinite Scalability?

    The main reason that I started migrating from PNG to SVG was Final Build Size + Performance... but if performance-wise it won't help very much... it would be better to just use SVG for extremely huge images, like a Map (for a top-down 2d game) and stuff that you would need at least a 2048x2048 PNG and then have a Hybrid game where it is like 20~30% SVG (Big Images) and 70~80% PNG (Small/Med Images).

    Also, when you import an SVG and choose "Generated Asset Type" to Textured Sprite, the pivot of the sprite doesn't work properly... it is set to always be on the bottom-left corner of the image. (links below)

    Image as SVG (Vector Sprite): https://i.imgur.com/mwguAtz.png (centered pivot, as expected)
    Image as SVG (Textured Sprite): https://i.imgur.com/h5yPnwG.png (set to center pivot, not working as expected)
    Image as SVG (Texture Sprite): https://i.imgur.com/jwxVAPu.png (how the image above looks on the editor when selected)
     
    Last edited: May 1, 2019
  28. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    SVG assets aren't necessarily suitable for every use case. The biggest win is the assets size which can stay very small even for very large content. Many people opt for SVG assets since they are very cheap to stream over the web, and they can be tessellated into sprites at runtime on the device.

    As you mentioned, performance is harder to quantify. For the most part, I would expect simple colored sprites to perform the same or faster than textured sprites (unless they are highly tessellated, which increase the required bandwidth). SVG sprites with embedded gradients and textures will be more GPU intensive than textured sprites. Performance also depend on the device's hardware, so its really hard to quantify.

    I can't provide a magic formula to compare SVG vs PNG, but antiAliasing (MSAA) should be quite performant despite the extra memory usage for the framebuffer, it will only call the fragment shader once per pixel, regardless of the number of samples.

    Thanks for reporting, it seems the "Pivot" property from the SVG inspector isn't working as expected. But if you go in the Sprite Editor and modify the pivot there, it should work. We'll provide a fix for the inspector part.
     
    Edan-Smith likes this.
  29. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Thank you for the reply.

    Are there any docs, tutorial or tips on how to achieve that? I tried finding info about it but my searches weren't very successful.
     
    Last edited: May 1, 2019
  30. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Edan-Smith likes this.
  31. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Sounds like there is some other bug/strange behavior @mcoted3d

    Here is a screenshot of a tree on inkscape: https://i.imgur.com/UYb88jI.png
    Here is a screenshot of the same tree on Unity: https://i.imgur.com/jxMBOvn.png (the shadow is weird, it shows on the editor like that as well and even if you change to a Texture, it remains like that)
    Here is a screenshot of the SVG settings: https://i.imgur.com/OHDJQEu.png
    Here is a screenshot of the nodes on Inkscape (very simple shape): https://i.imgur.com/k6qeOPy.png

    Sending the original SVG as attachment. (it happens on some other SVGs as well)
     

    Attached Files:

  32. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    That's a good one, it seems to be caused by overlapping triangles during the border tessellation phase. Thanks for reporting!
     
  33. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    @mcoted3d

    There's another which is similar to that "overlap" behavior.

    If on Inkscape you enable fill + stroke paint (outline), these are the results:
    - Inkscape (with stroke on): image
    - Unity (with stroke on from inkscape): image
    - Inkscape (with stroke off): image
    - Unity (with stroke off from inkscape): image

    Sending SVG as attachment.
     

    Attached Files:

  34. bigbadzone

    bigbadzone

    Joined:
    Jan 14, 2018
    Posts:
    16
    Just wanted to throw my own feedback in here: I've had my eyes on this for years. Vector support has come a long way in Unity. This is awesome!
    One thing I'd really like to be able to do in Unity is distort SVGs like sprite meshes, so I could replace my sprites with SVGs and create complex animations without any of the drawbacks and artifacting of raster graphics animation. This would usher in some really interesting art styles in 2D and 3D Unity games. Gradient mesh support would go a long way, then too. Imagine all that with the ability to edit paths realtime. Efficient vector graphics + GPU rendering is a 2D animation pipe dream.
    I know this is all way too ambitious, and I'm sure you guys are busy toiling away at some awesome stuff. Keep up the fantastic work!
     
    mcoted3d likes this.
  35. DorInception

    DorInception

    Joined:
    Jun 25, 2017
    Posts:
    8
    @mcoted3d
    We are also doing runt-time SVG loading
    its seems like on big SVGs the TessellateScene is taking a lot of time and is running on main thread.
    Is there a plan to make this async/multi threaded ?
     
  36. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    After looking at this more closely, this is a consequence of the way Unity SVG assets handle opacity, which is a bit different than what the SVG 1.1 specification describes.

    The specification wants us to apply opacity as if painting and filling is rendered on an intermediate layer, and the opacity should be then applied on that layer. We do not support this "opacity model", as this would require us to render part of the SVG tree into intermediate targets before applying the opacity change. You can imaging how expensive this would be, the intermediate render targets would have to be resized whenever the sprite takes a different size on the screen.

    Because of this, we apply the opacity directly on the shapes. This has the side-effect of having "cumulative" opacity, instead of having them "baked" into layers. We don't have any workaround for this at this time. I hope my explanations made sense. :)
     
  37. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    The tessellation is not multi-threaded right now, but the tessellation system has been designed to be completely side-effect free. So, there's nothing that prevents you from spawning a regular thread, call the TessellateScene() method in it and pass the tessellation result back to the main-thread to create the sprites.

    Hopefully this will be done transparently in the package using the job-system, eventually.
     
  38. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    This answer only applies to the "Stroke Paint" (outline) feature from inkscape OR it applies as well for the comment that you made on the previous reply "it seems to be caused by overlapping triangles during the border tessellation phase" from the other "bug" that I reported?
     
  39. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Both. Avoiding the generation of overlapping triangles for outlines would mitigate the issue, but the underlying cause would still be there. We will try to improve the outlines tessellation, but I don't see a short-term solution for the cumulative opacity issue.
     
  40. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Well, our current workaround is to externalize the shadow of the objects in a separate SVG, keep 100% opacity on inkscape, turn it into a Textured Sprite on unity and then change the alpha on unity's sprite renderer to adjust the opacity there.

    Thanks for all the clarifications.
     
    mcoted3d likes this.
  41. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    Another quick workaround for people who doesn't want to take that extra step of setting directly the pivot on the sprite, you can also directly set your pivot using the "Custom" dropdown option. Being 0.5, 0.5 the most common setting in case you want to center the sprite... etc (it works)
    (Attachment as example)
     
  42. DorInception

    DorInception

    Joined:
    Jun 25, 2017
    Posts:
    8
    This is how we try to do async:
    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.VectorGraphics;
    3. using System.IO;
    4. using System;
    5. using System.Collections.Generic;
    6. using System.Threading.Tasks;
    7.  
    8. namespace NetworkFramework
    9. {
    10.     public static class SVGExtensions
    11.     {
    12.         public static async Task<bool> SetImage(this SVGImage image, string url)
    13.         {
    14.             if (string.IsNullOrWhiteSpace(url))
    15.             {
    16.                 Debug.Log("url is null or empty");
    17.                 await Task.CompletedTask;
    18.                 return false;
    19.             }
    20.             try
    21.             {
    22.                 var (data, error) = await Network.Get(url, CachePolicy.ReturnCacheDataElseLoad);
    23.                 if (error != null)
    24.                 {
    25.                     Debug.LogError(error.Message);
    26.                     return false;
    27.                 }
    28.                
    29.                 // make sure the image was not destroyed before we try to apply the sprite
    30.                 if (image != null)
    31.                 {
    32.                     await image.LoadSpriteFrom(data); // apply to image
    33.                 }
    34.  
    35.                 return true;
    36.             }
    37.             catch (Exception e)
    38.             {
    39.                 Debug.LogException(e);
    40.                 await Task.CompletedTask;
    41.                 return false;
    42.             }
    43.         }
    44.  
    45.         private static async Task LoadSpriteFrom(this SVGImage image, byte[] data, SVGImportConfig config = null)
    46.         {
    47.             var str = System.Text.Encoding.Default.GetString(data);
    48.  
    49.             if (config == null)
    50.             {
    51.                 config = new SVGImportConfig();
    52.             }
    53.            
    54.             var sceneInfo = TryParseSVG(str, config);
    55.             if (sceneInfo.Scene == null || sceneInfo.Scene.Root == null)
    56.             {        
    57.                 Debug.LogError("Failed to Parse SVG");
    58.             }
    59.  
    60.             var rect = Rect.zero;
    61.             if (config.PreserveViewport)
    62.             {
    63.                 rect = sceneInfo.SceneViewport;
    64.             }
    65.  
    66.             var geometry = await GetSVGGeometry(config, sceneInfo);
    67.             if(geometry == null)
    68.             {
    69.                 Debug.LogError("geometry is null. this should not happen");
    70.                 return;
    71.             }
    72.            
    73.             var sprite = VectorUtils.BuildSprite(geometry, rect, config.SvgPixelsPerUnit, config.Alignment, config.CustomPivot, config.GradientResolution, true);
    74.             sprite.name = "Runtime Generated SVG";
    75.             image.sprite = sprite;
    76.         }
    77.  
    78.         private static SVGParser.SceneInfo TryParseSVG(string data, SVGImportConfig config)
    79.         {
    80.             var sceneInfo = new SVGParser.SceneInfo();
    81.            
    82.             using (TextReader stream = new StringReader(data))
    83.             {
    84.                 sceneInfo = SVGParser.ImportSVG(stream, 0, 1, 100, 100, config.PreserveViewport);
    85.             }
    86.             return sceneInfo;
    87.         }
    88.  
    89.         private static async Task<List<VectorUtils.Geometry>> GetSVGGeometry(SVGImportConfig config, SVGParser.SceneInfo sceneInfo)
    90.         {
    91.             var stepDist = config.StepDistance;
    92.             var samplingStepDist = config.SamplingStepDistance;
    93.             var maxCord = config.MaxCordDeviation;
    94.             var maxTangent = config.MaxTangentAngle;
    95.  
    96.             if (!config.AdvancedMode)
    97.             {
    98.                 // Automatically compute sensible tessellation options from the
    99.                 // vector scene's bouding box and target resolution
    100.                 config.ComputeTessellationOptions(sceneInfo, config.TargetResolution, config.ResolutionMultiplier, out stepDist, out maxCord, out maxTangent);
    101.             }
    102.  
    103.             var tessOptions = new VectorUtils.TessellationOptions
    104.             {
    105.                 MaxCordDeviation = maxCord,
    106.                 MaxTanAngleDeviation = maxTangent,
    107.                 SamplingStepSize = 1.0f / samplingStepDist,
    108.                 StepDistance = stepDist
    109.             };
    110.  
    111.             await Task.Run(() =>
    112.             {
    113.                 var geometry = VectorUtils.TessellateScene(sceneInfo.Scene, tessOptions, sceneInfo.NodeOpacity);
    114.                 return geometry;
    115.             });
    116.  
    117.             Debug.LogError("NOT WAITING");
    118.             return null;
    119.         }
    120.     }
    121. }
    122.  
    but for some reason we are getting the NOT WAITING error which causes the SVG not to load.
    any ideas as to way this is happening?
     
  43. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    Can you give a try to version 1.0.0-preview.26? We are now forcing the texture atlas to be a power-of-two size, which seems to help with Android devices.
     
  44. Amin-

    Amin-

    Joined:
    Sep 27, 2017
    Posts:
    25
    Hi @mcoted3d...
    "Vector Graphic" package is being built-in package in unity 2019.1(f2) ?!
    because I've seen nothing on the list! o_O
    Snap28.jpg
    What's happening there?
     
  45. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    You'll have to select "Show preview packages" from the "Advanced" menu.
     
    Amin- likes this.
  46. Edan-Smith

    Edan-Smith

    Joined:
    Jan 21, 2015
    Posts:
    24
    The "Sample Count" option on a "Textured Sprite" is just for the sprite generation quality (and it won't affect performance at all) or is it some special AA which is applied 24/7 at runtime to display the sprite better (affecting the rendering performance)?
     
  47. DorInception

    DorInception

    Joined:
    Jun 25, 2017
    Posts:
    8
    @mcoted3d
    Updating to preview 26 (and re-importing the asset) fixed the issue!
    Thanks a lot.
    I was thinking, maybe you want to expose the POT/NPOT option in the import settings. In case users might prefer less memory in exchange for not fully supporting some devices.

    Also, you think you can help us figure out the issue with the async Tasks (as in my previous post)?
     
  48. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    The sample count is just for the generated texture quality. It won't affect performances at runtime (it's just a regular Texture2D at that point).
     
    Edan-Smith likes this.
  49. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    315
    I'm not an expert with async/await, but my understanding is that await will resume the method execution when the task has completed running on a different thread. So in that sense, it's normal that you see the "NOT WAITING" message.

    You could try something like so:
    Code (CSharp):
    1. public static async Task<List<VectorUtils.Geometry>> GetSVGGeometryAsync(SVGParser.SceneInfo sceneInfo)
    2. {
    3.     // ...
    4.  
    5.     var geoms = await Task.Run(() =>
    6.     {
    7.         var geometry = VectorUtils.TessellateScene(sceneInfo.Scene, tessOptions, sceneInfo.NodeOpacity);
    8.         return geometry;
    9.     });
    10.  
    11.     return geoms;
    12. }
    13.  
     
  50. ryanslikesocool

    ryanslikesocool

    Joined:
    Jul 31, 2016
    Posts:
    4
    Hello again. I'm still in love with this package, though I have a question I was hoping someone could help with. Until about a day ago, I hadn't considered using anything but the editor while coding. Now that I realize that my game needs to be built and deployed eventually, I've come across a roadblock. I need to use SVGParser + SVGParser.SceneInfo at runtime in a built application, but I can't for the life of me figure out how to use it without a file path, since AssetBundles don't support true paths (as far as I know). Any ideas on how I can do this?

    EDIT: AssetBundles aren't necessary. I started using them thinking they could be a solution to my problem. Any method of loading SceneInfo is fine.