Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

YAML parser in Unity

Discussion in 'Scripting' started by audreylh, Jul 6, 2019.

  1. audreylh

    audreylh

    Joined:
    Oct 7, 2017
    Posts:
    9
    Deleted User likes this.
  2. ashapcott

    ashapcott

    Joined:
    Apr 4, 2019
    Posts:
    27
    As far as I know there is a YAML parser in the editor used internally but it isn't exposed in any fashion.
     
  3. harryr

    harryr

    Unity Technologies

    Joined:
    Nov 14, 2017
    Posts:
    38
    Can confirm, we don't expose a YAML serializer to users. Currently there's no plans for this to change I'm afraid.
     
    jemonsuarez likes this.
  4. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Can I ask why? It would be great to understand why ... is it because "its too much work and no one needs it", or some other hidden reasons? I'm just curious what the reasons are for certain things being internal only ... every now and then I definitely wish I had access to something thats behind a locked gate ;).

    I'm actually upgrading a project, and I have to manually fix a bunch of GUIDs in our timeline YAMLs. If you guys _did_ expose it, I could probably automate this much faster. Of course, I can do it myself if I really care and thought it would be worth the time vs what I have to fix (probably not) ... but it just begs the question ... is there a good reason not to, given all the editor tooling you guys let us do?
     
  5. harryr

    harryr

    Unity Technologies

    Joined:
    Nov 14, 2017
    Posts:
    38
    The former, from my understanding it's mainly that there hasn't been a enough demand for it to warrant the work internally to create the system as well as maintaining it.
     
  6. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    That makes sense. Its not so much that you guys are actively removing access to it, but rather, its extra work to provide access. If nothing else, that will make me feel a little better the next time I go "this would have been so simple if I just had access to X!!".

    Thanks ;).
     
    harryr likes this.
  7. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
    Any update on whether there is a way to access Unity's internal yaml API from a script?
     
  8. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    <- demand here
     
    KAJed and MikeAtOO like this.
  9. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,053
    Well, that's pointless. There are yaml parsers out there that you can use. Unity does not have a C# yaml parser. The serialization happens on the C++ side. So there is no "yaml API" to "expose". As harryr said, they would need to actually create such an API. Their yaml parser is only used on the C++ side with probably a ton of customized hacks. So providing a standardized API is a lot of work. Almost nobody is using yaml in production and if you really need to, there are a lot free parsers out there. Have you actually looked at any of those freely available solutions? If you think they are too complicated to use, what makes you think that if Unity would provide a solution it would be any simpler? ^^

    Yaml is a beast of a standard. It has so many special syntax rules and is extensible like no other.
     
    neonblitzer and Kurt-Dekker like this.
  10. Haxel0rd

    Haxel0rd

    Joined:
    May 20, 2021
    Posts:
    49
    oof ok, i just found this thread back and i cant remember why i even needed a YAML parser in the first place, but before posting in unity forums, i most likely will have tried available 3rd party solutions and wasn't happy with them. So i probably just wanted to add my 2 cents of demand for a solution made by unity, expecting this to perform better than 3rd party libs. Incase other people have demand for this too, they can add their demand here and maybe oneday there is enough demand that unity may implement this as a feature.

    Nevertheless, i understand from your post that there is atleast no hidden or already existing one.

    Thanks and best!
     
  11. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,053
    I don't get the point here. First of all Untiy is a game engine and a yaml parser itself has only a very tangential relationship with the engine itself. Also why would you expect a solution by Unity be better than a 3rd party solution? Better in which regards? For example Unity's JsonUtility is the fastest json object mapper, however it's also the most limited and doesn't work in many cases. So is it "better" or "worse" compared to other solutions?

    "Demanding" anything here in a forum won't work either. That's not really how a support forum works. Feature requests should be submitted on one of the road maps. You may have a hard time to pick an actual roadmap since basic programming tools are not the business of a game engine.

    Unity's own Yaml parser is only on the C++ side. So Unity currently does not have any .NET compatible Yaml parser and only a handful of people asking for it, so it's not worth the efford. Why should they invest $10k or $100k into a feature that only a few dozen people may need. On top of that Unity features are Unity specific. So chance are high that whatever they come up with may not satisfy your specific needs. You haven't even mentioned what your requirements are? What do you need it for? What should it support? Do you need a full fletched object mapper? What kind of objects and classes should be supported? Do you want to be able to parse any Yaml or is it enough to parse a format that Unity specifies, like their own internal format. If they ship a Yaml parser it most likely would be more in line with their format.

    Note that Yaml has a ton of features and a parser / serializer that supports all is probably rare. Also it always depends on the target format. Custom serializable classes? Fields or Properties?, Dictionary / List?
     
    Last edited: Apr 7, 2023
    ChloeCai and Kurt-Dekker like this.