Search Unity

Reading SVG files

Discussion in 'iOS and tvOS' started by malcolmr, May 10, 2010.

  1. malcolmr

    malcolmr

    Joined:
    Feb 18, 2010
    Posts:
    51
    I'm hoping to use SVG files as level descriptions for a game I am making so I can draw my levels quickly in Inkscape and then load them into Unity. However I'm having trouble finding a working C# SVG library. The only one I've found is SvgNet and I'm having trouble getting it to work.

    Are there any alternatives you'd recommend? It has to be something I can deploy on the iPhone.
     
  2. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,107
    Well, you could just read it as XML and take what you need from that. You won't be able to use many of the features anyway, unless you want to draw vector shapes with meshes and linerenderers for the outlines.

    One thing to note is that XML documents can get quite big, especially for large levels, and parsing them can potentially be quite slow, and you might need to do a lot of string operations.

    So just a suggestion, but an alternative would be to create a script that turns the relevant parts of the SVG data into some other format (maybe something binary?) and you parse that in Unity.
     
  3. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
  4. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,107
    Cool. However, that project seems to generate one big texture which probably isn't ideal for most games. But you can probably modify their code to get it to do what you need.