private IEnumerator CoLoadNavmeshFile(string path) { SGameEngine.AssetResource result = new SGameEngine.AssetResource(); yield return(MainGame.HeartBehavior.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_asset(path, typeof(TextAsset), result))); // 加载好的数据是否是当前场景的数据 uint stage_id = SceneHelp.GetFirstStageId(SceneHelp.Instance.CurSceneID); uint map_id = SceneHelp.GetMapIdByStageId(stage_id); string navmesh_file = "Assets/Res/NavMesh/" + map_id.ToString() + ".txt"; if (navmesh_file.Equals(path) == false) { yield break; } if (result.asset_ == null) { IsLoadingNavmeshFile = false; yield break; } TextAsset textAsset = result.asset_ as TextAsset; if (textAsset == null || textAsset.text == null) { IsLoadingNavmeshFile = false; Debug.LogError("LevelManager::CoLoadNavmeshFile, can not read navmesh file:" + path); yield break; } bool ret = XNavMesh.LoadBuffer(textAsset.bytes); if (!ret) { mCurNavmeshFile = string.Empty; GameDebug.LogError("navmesh LoadBuffer error : " + path); } else { mCurNavmeshFile = path; } result.destroy(); IsLoadingNavmeshFile = false; }
/// <summary> /// 加载关卡配置 /// </summary> /// <param name="id"></param> public void LoadLevelFile(uint stage_id, bool async) { string path = Id2Path(stage_id); LoadLevelFile(path, async); //Debug.LogError("test navmesh ........."); uint map_id = SceneHelp.GetMapIdByStageId(stage_id); string navmesh_file = "Assets/Res/NavMesh/" + map_id.ToString() + ".txt"; if (mCurNavmeshFile.Equals(navmesh_file) == false) { IsLoadingNavmeshFile = true; MainGame.HeartBehavior.StartCoroutine(CoLoadNavmeshFile(navmesh_file)); } }