Search Unity

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

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

  1. syamilsynz

    syamilsynz

    Joined:
    Dec 22, 2013
    Posts:
    31
    I'm using unity 5.3.2f1, SVG importer version 1.1.2 and MacBook Pro (late 2013) OS X El Capitan Version 10.11.3
     
  2. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thanks, could you also screenshot the settings of that specific SVG Asset?
    Or could you send me a stripped project so I can investigate it further?
    Thanks!
     
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @Jaroslav Stehlik
    I tried everything and circle is still miserable, i'm attaching my current settings, please look at them and advise, OR better if you can send a unity project with circle that renders fine on WebGL'd really great.
     

    Attached Files:

  4. syamilsynz

    syamilsynz

    Joined:
    Dec 22, 2013
    Posts:
    31
    This project before use unity early 2015 and then I updated it to current unity to implement svg. (I delete some of not necessary such as sprite/script). And sometimes its okay. and sometimes not.

    You can download the project in this link... https://www.dropbox.com/s/7k5mygnsmdzt1vp/kuiz.zip?dl=0

    However, when I create new unity project, it seems okay to use that .svg.

    Thanks.
     
  5. Arganoid

    Arganoid

    Joined:
    Oct 12, 2013
    Posts:
    24
    Could you clarify something regarding the "UGUI" format? The docs say:
    "Instead of triangles, Unity UI uses Quads. Because of this fact we have to emulate quads from triangles which suffer from wasted space about 1/4 of the original size"
    I assumed this meant that if I switch an SVG to this format, the .asset file would be 25% bigger, but when I try this with https://en.wikipedia.org/wiki/Flag_of_Bhutan there is no change in the size of the asset.
     
  6. shanemarks

    shanemarks

    Joined:
    Nov 8, 2012
    Posts:
    52
    Hi,

    I bought a license to test SVG importer. I created a simple SVG button and wanted to create a "sliced" sprite out of it. The SVG gets sliced in the svg-editor, but it does not appear to render / slice correctly when adjusting the width / height (the ui element is set to "sliced"). Do I need to set up the SVG in a specific way so that it can handle slicing correctly?

    I am using unity 5.3.2
     
  7. Blundig

    Blundig

    Joined:
    Jan 7, 2014
    Posts:
    18
    I'm running into an issue with the SVGFrameAnimator script (using Unity 5.3.2f1with SVG Importer 1.1.2)

    Previewing an animation in the editor works fine the first time. However, each time the scene is started after that, most of the animation frames will appear as pure pink. This will happen until the editor is restarted. I haven't tested this in a build, so don't know if it is just an editor problem.

    As a workaround, if you put separate instances of each frame into the scene (off camera), everything works as expected.
     
  8. Antti-Hamara-Sulake

    Antti-Hamara-Sulake

    Joined:
    Dec 31, 2014
    Posts:
    4
    I tried to update to SVG Importer v1.1.2 but I am getting Errors from SVG Image componet.
    IndexOutOfRangeException: Array index is out of range.
    SVGImporter.SVGImage.OnPopulateMesh (UnityEngine.UI.VertexHelper vh) (at Assets/SVG Importer/Plugins/Core/SVGImage.cs:480)
    UnityEngine.UI.Graphic.OnPopulateMesh (UnityEngine.Mesh m) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:433)
    UnityEngine.UI.Graphic.DoLegacyMeshGeneration () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:391)
    UnityEngine.UI.Graphic.UpdateGeometry () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:362)
    UnityEngine.UI.Graphic.Rebuild (CanvasUpdate update) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:324)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:149)
    UnityEngine.Canvas:ForceUpdateCanvases()
    SVGImporter.SVGPostprocessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/SVG Importer/Editor/AssetPostprocessor/SVGPostprocessor.cs:174)
    UnityEditor.AssetDatabase:SaveAssets()
    SVGImporter.SVGAssetEditor:ApplyChanges() (at Assets/SVG Importer/Editor/Core/SVGAssetEditor.cs:703)
    SVGImporter.SVGAssetEditor:OnFilesValid() (at Assets/SVG Importer/Editor/Core/SVGAssetEditor.cs:569)
    SVGImporter.SVGAssetEditor:OnInspectorGUI() (at Assets/SVG Importer/Editor/Core/SVGAssetEditor.cs:398)
    UnityEditor.DockArea:OnGUI()

    It seems like error comes if svg dose not have gradient, is imported in UGUI format and Gradients is set to Auto or Never.
    Error dose not happen if:
    • svg has gradient.
    • Gradients(import setting) is set to Always even if svg dose not have gradient.

    I use Unity 5.3.1.p2
     
  9. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi,

    When you are using Unity Native antialiasing please turn off the SVG Importer antialiasing on the asset it self.
    They should not combine. Hope that helps!
     
  10. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there, that part in docs should be corrected because this changed when Unity stopped using
    quads in the Unity UI so I think that form Unity 5.2 it behaves the same way as with SVG Renderer.
     
  11. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,
    With sliced images you have to setup the scale parameter on the SVG Asset itself.
    Hope that helps!
     
  12. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,
    You can use static batching for this purpose,
    That will bake the meshes into one big mesh and then you save a lot of performance.

    On the other hand
    Doing that more than once in a while could be much slower than having
    simply more draw calls.
     
  13. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,

    By most of the frames do you mean the thumbnails on the SVG Frame animator
    or the frames itself? Also, can you please post me on email an example of that scene
    with the assets? Thanks!
     
  14. Arganoid

    Arganoid

    Joined:
    Oct 12, 2013
    Posts:
    24
    Is there any downside for using UGUI instead of Opaque? (I need to use the SVGs both in the GUI and as normal objects)
     
  15. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,
    I have a fix for this,
    please send me your invoice number via email so I can send you the build.
    Cheers!
     
  16. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    UGUI which is nowadays basically the same render method as Transparent
    has a downside of a fillrate overhead.
    The Opaque rendering method which is not possible to render with the Unity UI
    has the great benefit that it does not render areas which are occluded by other opaque objects
    which conserves fillrate really a lot. But the disadvantage of opaque rendering is, that it works only on opaque
    graphics and it is much harder to manage the sorting because you have to sort it manually with zDepth offset
    and you cannot sort objects that simply as transparent objects.
     
    Last edited: Feb 20, 2016
  17. atamocius

    atamocius

    Joined:
    Aug 18, 2012
    Posts:
    8
    Hi, I am liking SVG Importer so far. The fact that the shapes are all meshes and thus resolution independent is really the main factor why I bought a license.

    Having said that, I am actually encountering a couple of bugs (or probably I am just missing something):
    • Once I create a prefab, the "Mesh" (in Mesh Filter) changes to "None" and the Material (in Mesh Renderer) changes to "None" as well.
    • Instantiating the prefab at runtime shows unexpected results, typically it turns pink and the sorting order has no effect (the prefab goes behind some assets instead of in front as dictated by the sorting layer)
    Is it possible to create a prefab from the SVG objects and instantiate them at runtime? Are there steps that I need to do in order for this to work properly?

    EDIT: I just want to add: when the object is instantiated and is pink, the Mesh Renderer's material is actually set to "None". Also, this typically happens around 80-90% of the time.

    EDIT: Restarting Unity appears to fix this (the material gets set to "SVG Importer/SolidColor/SolidColorAlpha"), but only on the first run. Succeeding runs turns all of the instantiated objects to pink.

    EDIT: I found a workaround, setting the "material" in the "SVG Renderer" component fixes the "pink" issue. Is this what I was supposed to do in the first place?
     
    Last edited: Feb 21, 2016
  18. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    I was having the same pink rendering issue as @Blundig and @r0undh0u53. I am using SVG Frame Animator extensively, and while everything worked great on the first run, it would also result in purple frames on the second and subsequent runs. Sometimes it would be random frames that would be pink, other times it would be all of them. Reimporting the assets or quitting/reopening Unity would fix the issue, but again, only for one run.

    Following @r0undh0u53's suggestion, I manually set the material of the SVG Renderer component to "Standard SVG Opaque" (opaque is the rendering format of my assets). This seems to have fixed the issue. Is this a workaround, or is this what I should have done in the first place?

    Thanks!

    - David
     
  19. Antti-Hamara-Sulake

    Antti-Hamara-Sulake

    Joined:
    Dec 31, 2014
    Posts:
    4
    Is there way to opt out Raycast Target on SVG Image component (UGUI) like in unity's on Image component?
     
  20. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,

    This definitely looks like a bug and I would investigate that further.
    Could you please send me on email some simple example scene?
    That would speedup the process a lot.
    Thanks!
     
  21. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
  22. atamocius

    atamocius

    Joined:
    Aug 18, 2012
    Posts:
    8
    Hi Jaroslav,

    Here is a Dropbox link to a sample project that illustrates the bug that I found: https://www.dropbox.com/s/zkqfl1zsacfv3dd/test-svg-instantiate-prefab.zip?dl=0 (For some reason, gmail is blocking the attachment of the zip file, so I'm using dropbox here instead).

    Here are the steps to replicate the issue:

    1. Load "Main.unity" scene
    - Take note of the "Test/Prefabs" folder which has 4 prefabs, 3 of which have missing materials and meshes (these went missing when I dragged the object from the Scene window to the Project window to create the prefab). the 4th one has a material called "SVG Opaque" that I created and is manually assigned.
    2. Run the scene
    - Notice that all the instantiated assets are rendered correctly
    3. Stop the scene
    4. Run again
    - Notice that all instantiated assets are now pink, except for the one prefab that I manually assigned a material to

    Also sent this to your support email.

    Thanks!
     
  23. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thanks! I will investigate it further.
    Sorry for the delay, but this week we are launching Mimpi Dreams which was made with SVG Importer
    so I am extremely busy right now.
    But I will fix it ASAP don't worry!
     
  24. dobidori

    dobidori

    Joined:
    Dec 25, 2015
    Posts:
    5
    I found a problem in SVGLengthConvertor.cs

    line 30 : value = float.Parse(_value, System.Globalization.CultureInfo.InvariantCulture);

    This line will stop the SVGImport to work if it fails converting string to float.
    The main problem is very simple because it can not convert 2 dots float numbers.
    For example, 2 dots svg path command L 1.35.68 should read as L 1.35,0.68 but currently it is doing float.Parse(“1.35.68”,) and finally generates “SVG Document Exception: Unknown char: .”
    It should call 2 times -
    float.Parse(“1.35”,)
    float.Parse(“.68”,)

    I see many great svgs which are always fail in this issue.
    But I love SVGImport and hope this issue to be fixed as soon as possible.

    Cheers!
     
  25. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi, please can you make that link private and send me to my email?
    Thanks!
     
  26. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    For sure it will.
    Thank your for your report.
    I will focus on the problem ASAP.
    For now, I am deeply sorry for the delay as we are just releasing our game
    Mimpi Dreams completely made with SVG Importer.
    Thank your for your patience.

    Have an awesome day!
     
  27. Blundig

    Blundig

    Joined:
    Jan 7, 2014
    Posts:
    18
    It is the frames themselves. The problem isn't related to SVGFrameAnimator specifically. I can reproduce it without using any scripts at all with these steps:

    1. Drag an SVG into an empty scene. Notice that the Mesh Renderer has a material (SVG Importer/SolidColor/SolidColorOpaque)
    Screen Shot 2016-02-25 at 8.25.48 AM.png
    2. Disable the game object in the Hierarchy.
    3. Hit play.
    4. While playing, manually enable the game object. Notice the image appears correctly. Now, manually disable the game object.
    4. Hit stop with the game object disabled (the problem seems to only appear if a hidden game object is shown and then disabled again during playback).
    5. Hit Play again. Enable the game object. Notice the material on the mesh renderer is gone. It will remain missing until Unity is restarted or the SVG is reimported.
    Screen Shot 2016-02-25 at 8.28.52 AM.png

    However, this doesn't happen with every material type. Switching to the GradientColorAlphaBlended material fixed the problem (for this test case, at least). Here are my original import settings for the image:
    Screen Shot 2016-02-25 at 8.32.29 AM.png

    vs settings on the same file that fix the problem:
    Screen Shot 2016-02-25 at 9.03.13 AM.png

    This is 100% reproducible with some SVG files in my project, but not all. I took a file that by default imported using GradientColorAlphaBlended and tried to force it to use SolidColorOpaque instead (by setting the import settings to Format=Opaque, Gradients=Never). In that case, the game object used 2 materials (SolidColorAlphaBlended, and SolidColorOpaque), and the problem would not occur.

    Hope this helps. I will email you test SVG file from above.
     
    Jaroslav-Stehlik likes this.
  28. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Hi,
    I tried the difusse shader ("SolidColorDiffuseAlphaBlended") and I realized it doesn't work with point lights, so I've made a shader that works:
    Code (CSharp):
    1. // Copyright (C) 2015 Jaroslav Stehlik - All Rights Reserved
    2. // This code can only be used under the standard Unity Asset Store End User License Agreement
    3. // A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
    4.  
    5. Shader "SVG Importer/SolidColor/SolidColorDiffuseAlphaBlendedv2"
    6. {
    7.     Properties
    8.     {
    9.         _MaxLights ("Max Lights", Int) = 4
    10.     }
    11.  
    12.     SubShader
    13.     {
    14.         Tags {"RenderType"="Transparent" "Queue"="Transparent" }
    15.         LOD 200
    16.         Lighting On
    17.         Blend SrcAlpha OneMinusSrcAlpha      
    18.         ZWrite Off
    19.         Cull Back
    20.         Fog { Mode Off }
    21.        
    22.         CGPROGRAM
    23.         #pragma surface surf Lambert alpha vertex:vert
    24.  
    25.         struct Input {
    26.             fixed4 color : COLOR;
    27.         };
    28.  
    29.         void vert (inout appdata_full v, out Input o)
    30.         {
    31.             v.normal = float3(0, 0, -1);
    32.             v.tangent = float4(-1, 0, 0, 1);
    33.    
    34.             UNITY_INITIALIZE_OUTPUT(Input, o);
    35.             o.color = v.color;
    36.         }
    37.  
    38.         void surf (Input IN, inout SurfaceOutput o) {
    39.             o.Albedo = IN.color.rgb;
    40.             o.Alpha = IN.color.a;
    41.         }
    42.         ENDCG
    43.     }
    44.  
    45.     Fallback "SVG Importer/SolidColor/SolidColorAlphaBlended"
    46. }
    47.  

    But I can't figure out how to make a Difusse shader for gradient SVG files. This is what I have right now:

    Code (CSharp):
    1. // Copyright (C) 2015 Jaroslav Stehlik - All Rights Reserved
    2. // This code can only be used under the standard Unity Asset Store End User License Agreement
    3. // A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
    4.  
    5. Shader "SVG Importer/GradientColor/GradientColorAlphaBlended Lit" {
    6.  
    7.     // texcoord0.x : Gradient X Transformation
    8.     // texcoord0.y : Gradient Y Transformation
    9.     // texcoord1.x : Image Index Integer
    10.     // texcoord1.y : Gradient Type Integer
    11.  
    12.     // _Params.x : Atlas Width
    13.     // _Params.y : Atlas Height
    14.     // _Params.z : Gradient width
    15.     // _Params.w : Gradient height
    16.  
    17.     Properties {
    18.         _GradientColor ("Gradient Color (RGBA)", 2D) = "white" { }
    19.         _GradientShape ("Gradient Shape (RGBA)", 2D) = "white" { }
    20.         _Params ("Params", Vector) = (1.0, 1.0, 1.0, 1.0)
    21.     }
    22.  
    23.     SubShader
    24.     {
    25.         Tags {"RenderType"="Transparent" "Queue"="Transparent" }
    26.         LOD 200
    27.         Lighting On
    28.         Blend SrcAlpha OneMinusSrcAlpha
    29.         ZWrite Off
    30.         Cull Back
    31.         Fog { Mode Off }
    32.  
    33.         Pass
    34.         {
    35.             Tags {"LightMode" = "ForwardBase"}
    36.             CGPROGRAM
    37.             #pragma vertex vert
    38.             #pragma fragment frag
    39.             //#pragma fragmentoption ARB_precision_hint_fastest
    40.             #pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
    41.             #include "UnityCG.cginc"
    42.             #include "Lighting.cginc"
    43.        
    44.             sampler2D _GradientColor;
    45.             sampler2D _GradientShape;
    46.             float4 _Params;
    47.        
    48.             struct vertex_input
    49.             {
    50.                 float4 vertex : POSITION;
    51.                 float2 texcoord0 : TEXCOORD0;
    52.                 float2 texcoord1 : TEXCOORD1;
    53.                 half4 color : COLOR;
    54.             };
    55.        
    56.             struct vertex_output
    57.             {
    58.                 float4 vertex : POSITION;          
    59.                 float2 uv0 : TEXCOORD0;
    60.                 float2 uv1 : TEXCOORD1;
    61.                 float4 uv2 : TEXCOORD2;
    62.                 half4 color : COLOR0;
    63.                 half3 diff : COLOR1;
    64.             };
    65.  
    66.  
    67.             vertex_output vert(appdata_full v)
    68.             {
    69.                 v.normal = float3(0, 0, -1);
    70.                 v.tangent = float4(-1, 0, 0, 1);
    71.        
    72.            
    73.                 vertex_output o;
    74.                 //UNITY_INITIALIZE_OUTPUT(Input, o);
    75.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);          
    76.                 o.uv0 = v.texcoord;
    77.                 o.color = v.color;
    78.            
    79.                 // half pixel
    80.                 float2 texelOffset = float2(0.5 / _Params.x, 0.5 / _Params.y);
    81.                 float imageIndex = v.texcoord1.x * _Params.z;
    82.            
    83.                 // Horizontal Start
    84.                 o.uv1.x = saturate((fmod(imageIndex, _Params.x) / _Params.x) + texelOffset.x);
    85.                 // Horizontal Width
    86.                 o.uv2 = saturate((1.0 - abs(float4(0.0, 1.0, 2.0, 3.0) - v.texcoord1.y)) * (_Params.z / _Params.x - texelOffset.x * 2.0));
    87.                 // Vertical Start
    88.                 o.uv1.y = saturate((floor((imageIndex / _Params.x) * _Params.w) / _Params.y) + texelOffset.y);
    89.  
    90.                 half3 worldNormal = UnityObjectToWorldNormal(v.normal);
    91.                 half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0));
    92.                 o.diff = nl * _LightColor0;
    93.                 // in addition to the diffuse lighting from the main light, add illumination from ambient or light probes
    94.                 // ShadeSH9 function from UnityCG.cginc evaluates it, using world space normal
    95.                 o.diff.rgb += ShadeSH9(half4(worldNormal,1));
    96.  
    97.                 return o;
    98.             }
    99.        
    100.             float4 frag(vertex_output i) : COLOR
    101.             {
    102.                 float gradient = dot(tex2D(_GradientShape, i.uv0), i.uv2) ;
    103.                 float2 gradientColorUV = float2(i.uv1.x + gradient, i.uv1.y);
    104.                 return tex2D(_GradientColor, gradientColorUV) * i.color * float4(i.diff.x, i.diff.y, i.diff.z, i.color.a);
    105.             }
    106.             ENDCG
    107.         }
    108.  
    109.  
    110.         Pass {
    111.             Tags {"LightMode" = "ForwardAdd"}
    112.             Blend One One
    113.             CGPROGRAM
    114.             #pragma vertex vert
    115.             #pragma fragment frag
    116.             #pragma fragmentoption ARB_precision_hint_fastest
    117.             #pragma multi_compile_fwdadd
    118.             #include "UnityCG.cginc"
    119.             #include "Lighting.cginc"
    120.             #include "AutoLight.cginc"
    121.        
    122.             sampler2D _GradientColor;
    123.             sampler2D _GradientShape;
    124.             float4 _Params;
    125.        
    126.             struct vertex_input
    127.             {
    128.                 float4 vertex : POSITION;
    129.                 float2 texcoord0 : TEXCOORD0;
    130.                 float2 texcoord1 : TEXCOORD1;
    131.                 half4 color : COLOR;
    132.             };
    133.        
    134.             struct vertex_output
    135.             {
    136.                 float4 vertex : POSITION;          
    137.                 float2 uv0 : TEXCOORD0;
    138.                 float2 uv1 : TEXCOORD1;
    139.                 float4 uv2 : TEXCOORD2;
    140.                 half4 color : COLOR0;
    141.                 half3 diff : COLOR1;
    142.                 LIGHTING_COORDS(3,4)
    143.             };
    144.  
    145.  
    146.             vertex_output vert(appdata_full v)
    147.             {
    148.                 v.normal = float3(0, 0, -1);
    149.                 v.tangent = float4(-1, 0, 0, 1);
    150.  
    151.                 vertex_output o;
    152.                 //UNITY_INITIALIZE_OUTPUT(Input, o);
    153.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);          
    154.                 o.uv0 = v.texcoord;
    155.                 o.color = v.color;
    156.            
    157.                 // half pixel
    158.                 float2 texelOffset = float2(0.5 / _Params.x, 0.5 / _Params.y);
    159.                 float imageIndex = v.texcoord1.x * _Params.z;
    160.            
    161.                 // Horizontal Start
    162.                 o.uv1.x = saturate((fmod(imageIndex, _Params.x) / _Params.x) + texelOffset.x);
    163.                 // Horizontal Width
    164.                 o.uv2 = saturate((1.0 - abs(float4(0.0, 1.0, 2.0, 3.0) - v.texcoord1.y)) * (_Params.z / _Params.x - texelOffset.x * 2.0));
    165.                 // Vertical Start
    166.                 o.uv1.y = saturate((floor((imageIndex / _Params.x) * _Params.w) / _Params.y) + texelOffset.y);
    167.  
    168.                 o.uv1 = ObjSpaceLightDir(v.vertex);
    169.                   TRANSFER_VERTEX_TO_FRAGMENT(o);
    170.  
    171.                 half3 worldNormal = UnityObjectToWorldNormal(v.normal);
    172.                 half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0));
    173.                 o.diff = nl * _LightColor0;
    174.                 // in addition to the diffuse lighting from the main light, add illumination from ambient or light probes
    175.                 // ShadeSH9 function from UnityCG.cginc evaluates it, using world space normal
    176.                 o.diff.rgb += ShadeSH9(half4(worldNormal,1));
    177.  
    178.                 return o;
    179.             }
    180.  
    181.  
    182.  
    183.             float4 frag(vertex_output i) : COLOR
    184.             {
    185.                 float gradient = dot(tex2D(_GradientShape, i.uv0), i.uv2) ;
    186.                 float2 gradientColorUV = float2(i.uv1.x + gradient, i.uv1.y);
    187.                 fixed atten = LIGHT_ATTENUATION(i);
    188.                 i.uv1 = normalize(i.uv1);
    189.                 fixed diff = saturate(dot(i.uv2, i.uv1));
    190.                 fixed4 tex = tex2D(_GradientColor, gradientColorUV) * i.color * float4(i.diff.x, i.diff.y, i.diff.z, i.color.a);
    191.  
    192.                 fixed4 c;
    193.                 c.rgb = UNITY_LIGHTMODEL_AMBIENT.rgb * 2 * tex.rgb;
    194.                 c.rgb += (tex.rgb * _LightColor0.rgb * diff) * (atten * 2);
    195.                 c.a = tex.a + _LightColor0.a * atten;
    196.                 return c;
    197.             }
    198.             ENDCG
    199.         }
    200.  
    201.     }
    202. }
    203.  
    Any tip out there?


    EDIT : Also SVGImporter generate console errors on SVGImage script when using SVGImage (using uGUI) if it had NOT any gradient in the import settings. So, if you use gradient = Always it works fine.
     
    Last edited: Feb 26, 2016
  29. ask80me

    ask80me

    Joined:
    Sep 17, 2015
    Posts:
    43
    Hello
    Puppet2d support please :)
    Thanks
     
  30. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @
    Jaroslav Stehlik

    Whatever i do , circle still render worst.
    I have tried so many time and im both disappointed and tired.

    I'd really appreciate if you can send a unity project with circle in it, that renders perfectly on webgl without pixelperfect enabled as i dont want to give up on you.
     
  31. leenk

    leenk

    Joined:
    Oct 1, 2015
    Posts:
    6
    Hi. We are having a problem with SVG importer. We are primarily extracting the generated meshes to be modified / recoloured / recombined etc, and attaching them to new game objects. This has been working very well, overall, and we are pleased with the results. However, when we try to directly use the svg assets produced by SVG importer, they behave unusually in the editor. For example, all svgs on the stage will "vanish" / "go invisible" when you hit UNDO or, more problematically, when you save the scene. They will only "come back" when you build. I think this only happens when an SVG is a child of another GameObject (for example within a character with hierarchically arranged body parts.)

    Is this a known issue, and is there a workaround / patch coming?

    I can provide a test project demonstrating this problem if that would help.

    I'm using Unity Professional v5.3.1f1 on a Windows 7 machine.
     
  32. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,

    Thanks for the info.
    The console warnings would be fixed in the next release.

    About the shader,
    Problem with transparent graphics and lights is that when your graphics has
    more than one overlapping layer, which happens in vector graphics all the time
    you would have very bad artefacts going on. This is due to the additive blending nature
    of lights. This looks Ok on opaque graphics but looks bad on transparent graphics.
    Will look on that this week.
     
  33. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hi there,
    Is the curves demo attached in the project good?
    You can find it in the following folder:
    SVG Importer/Example Project/Curves Demo
    WebGL demo: http://www.svgimporter.com/demos/curves/
    Because on my retina and non-retina monitors it looks sharp.
     
  34. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hello, Thanks for the info.
    Definitely send me a private link to that project.
    Thank you!
     
  35. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    This will be added in the next version of Unity.
    You can do it now programmatically.
    http://docs.unity3d.com/ScriptReference/UI.Graphic.html
    Raycast Target
     
  36. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    Hey,

    I'm using SVG Importer 1.1.2 (latest) and Unity 5.3.3p1 (64-bit).
    i'm getting this error on an empty project with a recently imported SVG Importer 1.1.2.

    Assets/SVG Importer/Plugins/Core/SVGAsset.cs(1494,109): error CS1061: Type `System.IO.FileInfo' does not contain a definition for `Length' and no extension method `Length' of type `System.IO.FileInfo' could be found (are you missing a using directive or an assembly reference?)

    This is the line with the error:

    output += ", FileSize: "+string.Format(new FileSizeFormatProvider(), "{0:fs}", fileInfo.Length);

    I haven't changed anything. What's going on?

    Thanks
     
  37. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Hello,

    This error happens mostly when you have the same class which has the same name in your project.
    Are you sure that this occurs in a blank project?
    If so, then it must be related to the patch version.
     
  38. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    Yeah, I created a new 2D project, and only added SVG Importer - nothing else, no other assets, no gameobjects (except the default Main Camera, etc) - and the error persists.

    SVG Importer 1.1.2 (latest) and Unity 5.3.3p1 (64-bit).
     
  39. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Whenever I get a System.IO error, it's usually because somehow the Build target got reset to WebPlayer on a Unity patch or update. Have you tried looking at File > Build Settings ?
     
    Jaroslav-Stehlik likes this.
  40. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    You were right, thanks! I just reinstalled unity and it got reset to web player. Didn't think to look there
     
  41. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Sorry,

    this error occurs on WebGL and I think I had fixed it.
    If you don't use the SVG importer mesh antialiasing I can send you a fixed version.
    Please send me an email if you are interested.
     
    raydekk likes this.
  42. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Just a little teaser about the upcoming update.

    I have made a little option called Use Layers which actually exposes the individual SVG Layers
    so you can then modify it, change the fill color or modify the gradient mapping etc.
    It will help us to support animation of the SVG graphics.

    The next step would be a nice user interface for working
    with layers "Please, don't expect illustrator-like editor"

    And we need a new tessellation technique to get uniform mesh for best-looking animations.
    If anyone has a good info about this topic, I would be glad to hear about that.

    I rewrote a huge amount of the plugin to make it more readable and extensible
    so the real-time import should be a little bit faster.

    Best regards for all SVG Importer users!


    Screen Shot 2016-03-02 at 14.29.21.png
     
  43. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    It's fine, I don't use WebGL, thanks!
     
  44. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    Hey Jaroslav,

    I noticed that gradients on strokes are not imported.
    Same thing for the type tool (any font).
    Are any of these features possible?
    Is the stroke gradient a bug? (Since gradients on anything else does work)

    Thanks
     
  45. Aduviel

    Aduviel

    Joined:
    Feb 18, 2016
    Posts:
    3
    Hi Jaroslav,

    Our team noticed that when we drag and drop an SVG Asset to the scene, an SVG Renderer and a texture/shader/material for the gradient is created. However, if we create an SVG Image for Unity GUI, and the SVG asset has a gradient, no gradient texture/shader material is created (when we run our project, the gradient picture becomes 100% white) Is this a known bug? and is there a workaround?

    For example as a workaround, can we take the auto-generated material from an SVG Renderer, save it as an asset, and use it for the SVG Image's material?

    Thanks,
    Ches
     
  46. dobidori

    dobidori

    Joined:
    Dec 25, 2015
    Posts:
    5
    Hello, I found a problem in SVGPaintable.cs

    line 800 :
    public bool IsLinearGradiantFill()
    {
    if (string.IsNullOrEmpty(this._gradientID))
    {
    return false;
    }
    return _linearGradList.ContainsKey(this._gradientID);
    }

    Many of my svgs lost Gradient when it was imported.
    The main problem is SVGImport could not find it’s key name of gradient.

    If _gradientID is inner side of <g>, for example
    <g…> <path… fill="url(#linearGradient-1)"> </path> </g>
    this method fails to find it.

    But if I move it to outside of <g> , for example
    <g…> </g> <path… fill="url(#linearGradient-1)"> </path>
    It works greatly as expected.

    Hope to be fixed ASAP with the other one that I pointed in the above thread.

    Cheers!
     
    Jaroslav-Stehlik likes this.
  47. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Gradients on strokes are not supported right at the moment but probably
    will be added in next plugin releases.
     
  48. Jaroslav-Stehlik

    Jaroslav-Stehlik

    Joined:
    Feb 20, 2012
    Posts:
    485
    Thanks for the bug report, Will take a look at ait!
     
  49. alphaprime

    alphaprime

    Joined:
    Jul 22, 2014
    Posts:
    4
    I have some svg shapes which open with Inkscape but not with SVG Importer. Is there something which can be edited in the svg file to fix this problem?
     

    Attached Files:

  50. dobidori

    dobidori

    Joined:
    Dec 25, 2015
    Posts:
    5
    Hello,

    How to scroll svg background ?
    Is it possible to use old style infinite scroll with offset ?
    GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(offset, 0));

    Thanks in advance!