Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by shdes161 · Nov 25, 2015 at 09:00 PM · savingapi

YAML support?

I'm pretty new to unity, and was wondering if there was a way to read/write to YAML files using the Unity API. I came from coding bukkit plugins (Minecraft Multiplayer server software) and its api had a built in feature that used yaml files. I wanted to see about using .yml files to store some data rather than player prefs or dealing with serialization. I looked on google and the unity documentation and haven't found anything useful, any info would be nice. Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Nov 26, 2015 at 02:51 AM

In short: no. The Unity editor uses YAML for asset serialization but only inside the editor. When you build your project all assets are stored in a binary format as it's smaller and loads faster. The UnityEngine doesn't include any YAML parser or generator. However there are plenty out there.

YAML is not necessarily a good choice for a serialization / data storage format. It's quite "verbose" and if it should be editable by humans its strict structure makes it sensitive for errors. As suggested by McKenzieG1 on the SO question i would also recommend to use JSON instead as it's much simpler and more versatile since it's more common even it has less "features" than YAML.

ps: You said you don't want to deal with serialization, but storing data in a text format is serializing the data. I barely programmed for Minecraft since i don't really like Java ^^. However it seems that Minecraft itself doesn't have support for YAML. Bukkit has added the FileConfiguration class which does this, Minecraft usually used NBT to store data which is actually very close to how PlayerPrefs are stored in a webplayer build. PlayerPrefs just don't support any structures.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shdes161 · Nov 26, 2015 at 01:51 PM 0
Share

Thank you for the answer. I was just wondering since saving strings or floats in YA$$anonymous$$L format would be easy to look up on occasion. I found a way to serialize what I needed, it's just more steps than I would have liked.

avatar image
1

Answer by a7BiT-psycho · Nov 26, 2015 at 03:49 PM

There is no built in YAML support. So youd either have to write your own implementation or use a .NET YAML library.

Most users decide to use JSON for saving and loading user data in Unity.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tacman1123 · Nov 13, 2020 at 01:17 PM

It's worse than it look -- it's a modified YAML format, most yaml parsers will throw an error.

First, it's multiple documents, separated by ---

But there are also duplicate keys, and sometimes line wraps. I'm not sure how they even parse it.

For example, from a .unity (scene) file (note the link break).

   m_LightingDataAsset: {fileID: 112000001, guid: fb3c98ad753fd9d4781da879935c9e93, 
 type: 2}
   m_UseShadowmask: 0
 --- !u!196 &4
 NavMeshSettings:
   serializedVersion: 2

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Nov 14, 2020 at 02:02 PM 0
Share

Well, first of all this question was about YA$$anonymous$$L support in Unity. So for runtime use, not to read Unity's own text based asset format which happens to be YA$$anonymous$$L. I'm not sure where you get that "modified" YA$$anonymous$$L format from. The "---" is the official document seperator and they use a label to define the internal Unity type (the "!u!196" after the "---") and a reference (the "&4") to indentify the object in the stream. YA$$anonymous$$L is a beast and highly complex. That's why YA$$anonymous$$L has a few critique points and is generally not considered "portable".

As for the line breaks, that's completely allowed ^^. Just have a look at more complex mapping examples in the specification. Curly braces indicate an inline mapping


I've written my own json parser because json is an extremely simple and robust format. I don't want to write a YA$$anonymous$$L or X$$anonymous$$L parser that satisfies the whole specification. I started writing my own X$$anonymous$$L parser and it's currently on hold because implementing even a subset of the specification is a nightmare. Especially when you think about entities and the billion laughs attack.

avatar image tacman1123 · Nov 14, 2020 at 03:15 PM 0
Share

You're right, @Bunny83 , my YA$$anonymous$$L parser doesn't support the whole spec.

And there's issues like strings beginning with zero not being quotes, which is being interpreted as octal. Ugh.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Play Services Cloud saving help. 0 Answers

About unity's API for android? 2 Answers

Using the Kongregate API 1 Answer

WWW : Waiting for response from server 1 Answer

Getting 403 Forbidden error when trying to post to FB wall 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges