Unity (Game Engine) Yaml parsing
See original GitHub issueHello,
I am trying to parse meta files from the game engine Unity to Json. (For a kind of self build level editor), now I try to parse the Yaml data with JS-Yaml, but I get an error.
The following Yaml:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 212: {fileID: 21200000}
- 61: {fileID: 6100000}
- 50: {fileID: 5000000}
- 114: {fileID: 11400001}
m_Layer: 14
m_Name: CamelGreen
m_TagString: Plane
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &100002
...
Throws the error:
JS-YAML: unknown tag !<tag:unity3d.com,2011:1> at line 22, column 1:
--- !u!1 &100002
^
...\node_modules\js-yaml\lib\js-yaml\loader.js:154
throw generateError(message);
^
YAMLException: JS-YAML: undeclared tag handle "!u!" at line 22, column 9:
--- !u!1 &100002
But as far as my limited knowledge about Yaml goes, I do see a TAG declaration at the top of the Yaml file.
Then I tried to declare a custom tag:
var spaceYamlType = new yaml.Type('!u!', {
loader: {
kind: 'object',
resolver: function (object) {
return object;
}
},
dumper: {
kind: 'object',
instanceOf: Object
}
});
var SPACE_SCHEMA = yaml.Schema.create([ spaceYamlType ]);
(Yes, that is code straight copied from the example) But that didn’t work either (same error).
Any idea what is going wrong here?
Arco
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:17 (1 by maintainers)
Top Results From Across the Web
UnityYAML - Unity - Manual
Unity uses a custom-optimized YAML library called UnityYAML. ... the scalar returns This is a and might trigger an Asset into further parsing....
Read more >YAML parser in Unity
There are yaml parsers out there that you can use. Unity does not have a C# yaml parser. The serialization happens on the...
Read more >YAML Config File Reader for Unity 3D - Zsolt Balai
This is a package to read this type of file into unity objects. It is in C#, but can be called from Javascript...
Read more >[Fixed] Unable to parse YAML file in Unity 3d project - Morioh
[Fixed] Unable to parse YAML file in Unity 3d project. ... Unity 3D is the trending game app development framework to serve the...
Read more >Unity Developers Guide | Parse
You simply set whatever key-value pairs you want, and our backend will store it. For example, let's say you're tracking high scores for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If anyone happens to come across this, this is the code that I’m using (in 2020/2021) to load prefab and script files:
You can just import that anywhere, something like (assuming a file named
readUnityFile.js
):You must use
loadAll
function to load multi-document sources. See the README.