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); }
// Initialization void Awake() { #if (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && !SS_GAMESENSE_DISABLED if (_mInstance == null) { // update the static reference _mInstance = this; } else { // no other instances should exist _logWarning("Another GameSense client script is getting instantiated. Only a single instance should exist at any time"); Destroy(this.gameObject); return; } // need to survive scene loading DontDestroyOnLoad(this.gameObject); // initialize _mSerializer = new FullSerializer.fsSerializer(); _mMsgQueue = new LocklessQueue <QueueMsg>(_MsgQueueSize); _mGameSenseWrk = new System.Threading.Thread(_gamesenseWrk); // check for exceptions _mGameSenseWrkShouldRun = true; _setClientState(ClientState.Probing); try { _mGameSenseWrk.Start(); // add events if the script is attached to GameSenseManager prefab if (gameObject.name.Equals(_GameSenseObjName)) { _addGUIDefinedEvents(); } } catch (System.Exception e) { _logException("Could not start the client thread", e); _setClientState(ClientState.Inactive); } #endif // (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && !SS_GAMESENSE_DISABLED }
/// <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); }