[Fixed] Unable to parse YAML file in Unity 3d project

阅读: 评论:0

[Fixed] Unable to parse YAML file in Unity 3d project

[Fixed] Unable to parse YAML file in Unity 3d project

Sometimes you may get following errors:Unable to parse YAML file: [mapping values are not allowed in this context] at line 1

 or

Unable to parse YAML file: [could not find expected ‘:’] at line 2

Both of those errors usually caused by version control system (eventually by user).
In first case svn added <<<<<<< .mine in to .meta file after conflict.
In second case it was git, added text to highlight conflict.

To fix those errors you just need to go though all .meta files and fix svn or git conflicts.

For git you can use ruby script that you can find on Ashley Whetter’s Blog
For svn just adapt ruby script to look for “<<<<” inside files instead of “:” or write your own script 

Recently I came across the following error when working on a group Unity3D project:

Unable to parse YAML file: [could not find expected ':'] at line 2

We had no yaml files (that we knew of) and Unity could still build and run the project so this error seemed a bit odd.

It turns out that the error was caused by git adding text to highlight a conflict in some of Unity's .meta files. So fixing the error was just a case of finding the meta files and resolving the conflicts.

I used this ruby script to find the files that needed to be fixed. Just place the script in the root of the Unity project and run it. It'll print the locations of the broken files.

ruby源码

require 'find'metafiles = []
Find.wd()) do |path|metafiles << path if path =~ /.*.meta$/
endmetafiles.each do |fileloc|file = File.open(fileloc)line = nil2.times{line = s}puts fileloc if not line =~ /.*:.*/file.close
end

很完美



本文发布于:2024-01-27 23:48:19,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063705173378.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:parse   Unable   Fixed   YAML   project
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23