public void GetHXInfoFromServer(string projectid, HXInfo hXInfo) { ProjectRootInfo projectRootInfo = null; Loading loading = loadingManager.AddALoading(0); netCtrlManager.WebRequest( "获取项目信息", pathAndURL.serverProjectInfoFinalUrl, loading.LoadingAnimation, (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { //网络未连接且 string log = "未能连接服务器"; GlobalDebug.Addline(log); Debug.Log(log); }, (DownloadHandler t) => { string log4 = "已连上服务器"; GlobalDebug.Addline(log4); Debug.Log(log4); projectRootInfo = JsonUtility.FromJson <ProjectRootInfo>(t.text); projectRootInfo.data.projectid = projectid; OnLoadHXinfoFromServer(projectRootInfo, hXInfo); }, null, null ); }
void OnLoadProjectAssetBundlesInfo(ProjectAssetBundlesInfo a, string projectID, string hxAssetBundleName) { projectAssetBundlesInfo = a; for (int i = 0; i < projectAssetBundlesInfo.sceneAssetBundle.Length; i++) { if (projectAssetBundlesInfo.sceneAssetBundle[i] == hxAssetBundleName) { HXInfo newHXInfo = new HXInfo(); newHXInfo.hxSenePath = projectAssetBundlesInfo.needExportScenePath[i]; newHXInfo.hash = projectAssetBundlesInfo.sceneAssetBundleHash[i]; newHXInfo.crc = projectAssetBundlesInfo.sceneAssetBundleCRC[i]; newHXInfo.hxAssetBundleName = hxAssetBundleName; newHXInfo.projectID = projectID; assetBundleManager.LoadAssetBundleAndAddToSceneInARMode(projectID, newHXInfo); } } }
void OnLoadHXinfoFromServer(ProjectRootInfo p, HXInfo hXInfo) { if (p != null) { for (int i = 0; i < p.data.hxInfo.Length; i++) { if (p.data.hxInfo[i].modeName == hXInfo.modeName) { p.data.hxInfo[i].modeName = hXInfo.modeName; p.data.hxInfo[i].hxAssetBundleName = hXInfo.hxAssetBundleName; p.data.hxInfo[i].hxSenePath = hXInfo.hxSenePath; p.data.hxInfo[i].hash = hXInfo.hash; p.data.hxInfo[i].crc = hXInfo.crc; p.data.hxInfo[i].projectID = hXInfo.projectID; p.data.hxInfo[i].senceInteractiveInfo = hXInfo.senceInteractiveInfo; // p.data.hxInfo[i].mode3Ddisplay = p.data.hxInfo[i].mode3Ddisplay; hXInfo = p.data.hxInfo[i]; hXInfo.senceInteractiveInfo.huXingType.introduction = hXInfo.discr; hXInfo.senceInteractiveInfo.huXingType.normalArea = float.Parse(hXInfo.area); hXInfo.senceInteractiveInfo.huXingType.fangXing = hXInfo.modeFormat; foreach (HuXingType.floor f in hXInfo.senceInteractiveInfo.huXingType.allFloor) { if (f.fczMesh != null) { f.fczMesh.gameObject.SetActive(false); } } hasLoadedHXinfo.Add(hXInfo); // assetBundleManager.sceneInteractiveManger.arManager.CheckCurrentState(); return; } } } Debug.LogError("未找到项目" + p.data.projectid + "得户型" + hXInfo.modeName); }
//for AR public void LoadAssetBundleAndAddToSceneInARMode(string projectID, HXInfo hXInfo) { foreach (HXInfo h in hxInfoCache.hasLoadedHXinfo) { Debug.Log(h.projectID); Debug.Log(h.hxAssetBundleName); //判断是否已经加载 if (h.projectID == hXInfo.projectID && h.hxAssetBundleName == hXInfo.hxAssetBundleName) { Debug.Log("已加载" + h.projectID + "_" + h.hxAssetBundleName + " AssetBundle"); // sceneInteractiveManger.arManager.findSenceInteractiveInfo = h.senceInteractiveInfo; // sceneInteractiveManger.arManager.CheckCurrentState(); return; } } Loading loading = loadingManager.AddALoading(6); // loadingAssetBundleTotalInfo.OpenTotalInfo(1); circlePointCurrent = 0; netCtrlManager.WebRequest( "正在加载户型", pathAndURL.serverAssetBundlePath + hXInfo.hxAssetBundleName + "^" + pathAndURL.projectPath + hXInfo.hxAssetBundleName + "," + hXInfo.hash + "," + hXInfo.crc, loading.LoadingAnimation, (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.Log("LoadAddSingerScene Failed!"); }, null, null, (DownloadHandlerAssetBundle t) => { currentLoadedSceneAssetBundles.Add(t.assetBundle); // loadingAssetBundleTotalInfo.CloseTotalInfo(); Loading loadingScene2 = loadingManager.AddALoading(5); foreach (Transform tr in loadingScene2.GetComponentsInChildren <Transform>()) { if (tr.name == "BG") { // tr.gameObject.SetActive(false); } } loadingScene2.LoadingAnimation(SceneManager.LoadSceneAsync(hXInfo.hxSenePath, LoadSceneMode.Additive), "正在加载"); loadingScene2.OnLoadedEvent.AddListener ( () => { hXInfo.senceInteractiveInfo = sceneInteractiveManger.senceInteractiveInfoGroup[sceneInteractiveManger.senceInteractiveInfoGroup.Count - 1]; //获取刚添加Assetbundle的户型名 hXInfo.modeName = hXInfo.senceInteractiveInfo.huXingType.hxName; // sceneInteractiveManger.arManager.findSenceInteractiveInfo = hXInfo.senceInteractiveInfo; hxInfoCache.GetHXInfoFromServer(projectID, hXInfo); } ); } ); }