chyh1990 / yaml-rust

A pure rust YAML implementation.
Apache License 2.0
600 stars 139 forks source link

Support for Unity #141

Open forrestthewoods opened 4 years ago

forrestthewoods commented 4 years ago

Hi. I want to leverage yaml-rust to open, modify, and save Unity scene files. Out the gate I've hit multiple issues.

1. Can't parse common scene files. This is due to the error: mapping values are not allowed in this context at line ### column ##

Scene files frequently contains lines such as this: --- !u!114 &137567736 stripped

This is apparently a common issue. This may be invalid YAML. I'm not sure.

2. Missing tag support Unity makes heavy use of document tags. If yaml-rust can load a unity scene file then emitting it back out drops all of the document tags. This is a catastrophic failure.

--- !u!29 &1

3. Different emitter style Unity's YAML is compact. m_LocalPosition: {x: 0, y: 3, z: 0}

yaml-rust is not.

m_LocalPosition:
    x: 0
    y: 3
    z: 0

Number 1 may be invalid YAML syntax, in which case it should probably be handled separately and more explicitly. But #2 and #3 seem like they should be correct to fix?

neithernut commented 4 years ago

Disclaimer: not a maintainer.

If you already enumerate different points of incompatibility, maybe it makes sense to split the issue up. It makes much more sense to track the individual points, imo.

Unity's YAML is compact. m_LocalPosition: {x: 0, y: 3, z: 0}

This is simply a flow-style map (YAML defines a block and a flow style)

forrestthewoods commented 4 years ago

If you already enumerate different points of incompatibility, maybe it makes sense to split the issue up.

I thought about that. Ultimately it’s likely to be a series of issues. The value of each individual did may be minimal. I figured it’s better to start with the real goal (work with Unity) and break it up later if appropriate.