/// <summary> /// 解析该yaml文本,参数:绝对路径 /// </summary> /// <param name="pFullPath">绝对路径</param> static public void ResolveYaml(string pFullPath, bool pForceResolve = false) { if (!File.Exists(pFullPath)) { Debug.LogErrorFormat("不存在该路径:" + pFullPath); return; } if (!mInitScriptGuid) { mInitScriptGuid = true; InitScriptGuid(); } if (!pForceResolve && sResolverDic.ContainsKey(pFullPath)) { Debug.LogErrorFormat("已存在解析数据:" + pFullPath); return; } try { var tResolver = new YamlResolver(); if (!sResolverDic.ContainsKey(pFullPath)) { sResolverDic.Add(pFullPath, null); } sResolverDic[pFullPath] = tResolver; tResolver.Resolve(pFullPath); } catch (Exception ex) { Debug.LogException(ex); } }
/// <summary> /// 获取解析器 /// </summary> /// <param name="pFileID"></param> /// <returns></returns> static public YamlResolver GetResolver(string pFullPath, bool pIfNullResolve = false) { if (YamlResolver.sResolverDic == null) { return(null); } YamlResolver tResolver = null; YamlResolver.sResolverDic.TryGetValue(pFullPath, out tResolver); if (tResolver == null && pIfNullResolve) { YamlResolver.ResolveYaml(pFullPath, true); return(GetResolver(pFullPath, false)); } return(tResolver); }
static public void TestMethod() { YamlResolver.ResolveYaml(Path.Combine(Application.dataPath, "Test/" + cPrefabName), true); }