public NodeGroup LoadNodeGroupByJson(string path) { string content = ""; #if UNITY_EDITOR if (File.Exists(path)) { content = File.ReadAllText(path); } #else content = xc.DBManager.Instance.LoadDBFile(path.Replace("Assets/Res/", "")); #endif if (string.IsNullOrEmpty(content) == true) { return(null); } NodeGroup temp = null; FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(content); var serializer = new FullSerializer.fsSerializer(); var processor = new FileSerializerProcessor(); serializer.AddProcessor(processor); serializer.TryDeserialize(fsdata, ref temp); if (temp != null) { RemoveNodeGroup(temp.Id); InitNodeGroup(temp); nodeGroups.Add(temp.Id, temp); return(temp); } return(null); }
/// <summary> /// 协程加载关卡配置 /// </summary> /// <param name="path"></param> /// <returns></returns>\ private IEnumerator CoLoadLevelFile(string path) { SGameEngine.AssetResource result = new SGameEngine.AssetResource(); yield return(MainGame.HeartBehavior.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_asset(path, typeof(TextAsset), result))); if (result.asset_ == null) { yield break; } TextAsset textAsset = result.asset_ as TextAsset; if (textAsset == null || textAsset.text == null) { result.destroy(); Debug.LogError("LevelManager::CoLoadLevelFile, can not read level file:" + path); yield break; } Neptune.Data data = new Neptune.Data(); FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(textAsset.text); var serializer = new FullSerializer.fsSerializer(); var processor = new Neptune.FileSerializerProcessor(); serializer.AddProcessor(processor); serializer.TryDeserialize <Neptune.Data>(fsdata, ref data); if (data == null) { result.destroy(); yield break; } OnLevelLoadFinished(data); ObjCachePoolMgr.Instance.RecycleCSharpObject(data, ObjCachePoolType.JSON, path); result.destroy(); }
Neptune.Data LoadLevelFileTemporary(string path) { Neptune.Data data = null; if (m_NepCache.TryGetValue(path, out data)) { return(data); } string text = DBManager.Instance.LoadDBFile(path.Replace("Assets/Res/", "")); if (string.IsNullOrEmpty(text) == true) { return(null); } data = new Neptune.Data(); FullSerializer.fsData fsdata = FullSerializer.fsJsonParser.Parse(text); var serializer = new FullSerializer.fsSerializer(); var processor = new Neptune.FileSerializerProcessor(); serializer.AddProcessor(processor); serializer.TryDeserialize <Neptune.Data>(fsdata, ref data); if (data == null) { return(null); } if (m_NepCache.Count >= 3) { string first_path = m_NepPath.Dequeue(); m_NepCache.Remove(first_path); } m_NepCache[path] = data; m_NepPath.Enqueue(path); return(data); }