Beispiel #1
0
        public static YamlObject[] FindScriptInSceneFile(string sceneFile, string guid, bool searchMultiple = true)
        {
            if (sceneFile == string.Empty)
            {
                return new YamlObject[] { }
            }
            ;

            List <YamlObject> objects = new List <YamlObject>();

            try {
                var file = new FileInfo(sceneFile);

                var scope = new YamlScope();
                using (var input = file.OpenText()) {
                    while (scope.Parse(input))
                    {
                        if (scope.IsScript(guid))
                        {
                            objects.Add(new YamlObject(scope));
                            if (!searchMultiple)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                Debug.LogException(e);
            }

            return(objects.ToArray());
        }
Beispiel #2
0
        public static YamlObject ParseAsset(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            YamlObject @object = null;

            try {
                var file  = new FileInfo(path);
                var scope = new YamlScope();
                using (var input = file.OpenText()) {
                    if (scope.Parse(input))
                    {
                        @object = new YamlObject(scope);
                    }
                }
            }
            catch (Exception e) {
                Debug.LogException(e);
            }

            return(@object);
        }
Beispiel #3
0
 public YamlObject(YamlScope scope)
 {
     foreach (var line in scope.Lines)
     {
         var delimiter = line.IndexOf(':');
         if (delimiter < 0)
         {
             continue;
         }
         var isEmpty = delimiter == line.Length;
         Fields.Add(line.Substring(0, delimiter).Trim(),
                    new YamlEntry()
         {
             Value = isEmpty ?
                     string.Empty :
                     line.Substring(delimiter + 1, line.Length - delimiter - 1).Trim()
         });
     }
 }