Example #1
0
    public void OnAllAssetBundleLoaded()
    {
        currentAddSceneID = 0;
        GlobalDebug.Addline("OnAllAssetBundleLoaded");
        Debug.Log("OnAllAssetBundleLoaded");

        defaultGUI.triggerCancelBtn.AlphaPlayBackward();

        //已经开始循环加载场景
        isLoopingAddSource = true;

        switch (appBridge.appProjectInfo.sceneLoadMode)
        {
        case "0":
            //加载主场景
            Loading loadingScene = loadingManager.AddALoading(5);
            loadingScene.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[0], LoadSceneMode.Additive), "正在加载");
            loadingScene.OnLoadedEvent.AddListener(() => { StartCoroutine(LoadSenceInteractiveIE()); });
            break;

        case "1":
            //不加载主场景,只加载户型,跳过第一个主场景
//             defaultGUI.triggerMusic.AlphaPlayBackward();
            currentAddSceneID = 0;
            LoopAdditiveScene(true);
//                arManager.OpenARCamrea();
            break;

        case "2":
            //加载主场景,并且激活
            Loading loadingScene3 = loadingManager.AddALoading(5);
            loadingScene3.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[0], LoadSceneMode.Additive), "正在加载");
            loadingScene3.OnLoadedEvent.AddListener(() => { StartCoroutine(LoadSenceInteractiveIE()); });
            break;

        case "8":
            //不加载主场景,只加载户型,以供AR扫描,跳过第一个主场景
//                currentAddSceneID = 0;
//                LoopAdditiveScene(true);

//                arManager.OpenARCamrea();
            break;

        case "9":

            //加载主场景且打开在线讲
            Loading loadingScene2 = loadingManager.AddALoading(5);
            loadingScene2.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[0], LoadSceneMode.Additive), "正在加载");
            loadingScene2.OnLoadedEvent.AddListener(() => { StartCoroutine(LoadSenceInteractiveIE(true)); });
            appBridge.serverProjectInfo.Trigger_ToPanoramaBtn.AlphaPlayBackward();


            break;
        }
    }
Example #2
0
    public void GetProjectInfoFromServer(string projectid)
    {
        Loading loading = loadingManager.AddALoading(0);

        netCtrlManager.WebRequest(
            "获取项目信息",
            pathAndURL.serverProjectInfoFinalUrl,
            loading.LoadingAnimation,
            (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) =>
        {
            Debug.Log("ServerProjectInfo Load Failed!");
            //网络未连接且
            if (hasLocalCached)
            {
                projectRootInfo = JsonUtility.FromJson <ProjectRootInfo>(File.ReadAllText(pathAndURL.localProjectInfoPath));
                projectRootInfo.data.projectid = projectid;
                PrcessProjectInfo(projectRootInfo, true);
                loading.FinishLoading();
            }
            else
            {
                //                loading.displayInfo=""
            }
        },
            (DownloadHandler t) =>
        {
            ProcessProjectInfoText(projectid, t.text);
        },
            null,
            null
            );
    }
Example #3
0
    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
            );
    }
Example #4
0
    void LoopLoadAndCacheImageFromServer(int currentID)
    {
        //是否需要打断加载
        if (SceneInteractiveManger.needBreakLoad)
        {
            GlobalDebug.Addline("Break Load Image");
            Debug.Log("Break Load Image");
            assetBundleManager.sceneInteractiveManger.unload.LoadUnloadScene();
            return;
        }

        string imageSeverlLoadPath = pathAndURL.imageFinalUrl + allNetTextrue2D[currentID].url;

//     string imageSeverlLoadPath = "http://123.59.40.145/APP/allproject/201708240001/" + allNetTextrue2D[currentID].url;

        Debug.Log(imageSeverlLoadPath);
//     Debug.Log(allNetTextrue2D[currentID].texName);
//     Debug.Log(allNetTextrue2D[currentID].url);
        Debug.Log(pathAndURL.localImageCachePath + "/" + allNetTextrue2D[currentID].texName);

        //本地有存在此图片就不再从服务器上下载
        if (File.Exists(pathAndURL.localImageCachePath + "/" + allNetTextrue2D[currentID].texName))
        {
            GlobalDebug.Addline("图片已缓存: " + allNetTextrue2D[currentID].texName);
            allNetTextrue2D[currentID].hasLocalCached = true;
            LoadNext();
            return;
        }

        Loading loading = loadingManager.AddALoading(4);

        netCtrlManager.WebRequest("Loading:" + allNetTextrue2D[currentID].texName, imageSeverlLoadPath, loading.LoadingAnimation,
                                  (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.LogError(imageSeverlLoadPath + " Load Failed!");  LoadNext(); },
                                  null,
                                  (DownloadHandlerTexture t) =>
        {
            File.WriteAllBytes(pathAndURL.localImageCachePath + "/" + allNetTextrue2D[currentID].texName, t.data);
            //下载的图片暂时不用,所以要销毁.再用的时候从图片缓存里提取

            GlobalDebug.Addline("下载图片到本地: " + allNetTextrue2D[currentID].texName);
            //OnCached会保留下载的图片.如果此图片有被使用.如果此图片没有被使用则会被Destroy;
            allNetTextrue2D[currentID].OnLocalCached(t.texture);
            LoadNext();
        },
                                  null
                                  );
    }
Example #5
0
    public void GetProjectInfoFromServer(string projectid)
    {
        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);

            if (hasLocalCached)
            {
                string log2 = "未能连接服务器,但是有缓存";
                GlobalDebug.Addline(log2);
                Debug.Log(log2);

                loadSceneFromCache = true;

                projectRootInfo = JsonUtility.FromJson <ProjectRootInfo>(File.ReadAllText(pathAndURL.localProjectInfoPath));
                projectRootInfo.data.projectid = projectid;

//                      Debug.Log(File.ReadAllText(pathAndURL.localProjectInfoPath));
                PrcessProjectInfo(projectRootInfo, true);
                loading.FinishLoading();
            }
            else
            {
                string log3 = "未能连接服务器,且没有缓存";
                GlobalDebug.Addline(log3);
                Debug.Log(log3);
            }
        },
            (DownloadHandler t) =>
        {
            string log4 = "已连上服务器";
            GlobalDebug.Addline(log4);
            Debug.Log(log4);

            loadSceneFromCache = false;
            ProcessProjectInfoFromServer(projectid, t.text);
        },
            null,
            null
            );
    }
Example #6
0
    public void SucessConnectGUI()
    {
        remoteManger.isOtherSideOnline     = true;
        remoteManger.lastIsOtherSideOnline = true;

        if (remoteManger.runAtType == RemoteManger.RunAtType.Slave)
        {
            touchBlock.AlphaPlayForward();
        }

        SetHelpInfoString("成功连线!开始讲盘");
        infoLabelGroup[4].text = "已连接";
        infoLabelGroup[5].text = "已连接";
        GlobalDebug.Addline("成功连线!开始讲盘");
        Debug.Log("成功连线!开始讲盘");

        bg_Group.AlphaPlayBackward();

        //只要连接上后,全屏的连接提示就不使用;
        bg_Group_Trriger.AlphaPlayBackward();


        vedio_Trriger.AlphaPlayForward();

        if (!hasHeadIcoLoaded)
        {
            Loading loading = loadingManager.AddALoading(4);
            netCtrlManager.WebRequest("Loading:" + "HeadImage", appBridge.appProjectInfo.remoteUserHeadUrl, loading.LoadingAnimation,
                                      (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.LogError("头像下载失败!"); },
                                      null,
                                      (DownloadHandlerTexture t) =>
            {
                avatarICO.texture = t.texture;
                hasHeadIcoLoaded  = true;
            },
                                      null
                                      );
        }//这是重新连接后的状况
        else
        {
        }
    }
    //如果OnCached非空,只会缓存AssetBundles,且调用OnCached
    public void LoadProjcetAssetBundlesCache(string inProjectID, UnityAction <ProjectAssetBundlesInfo, string, string> OnCached = null, string hxAssetBundleName = null)
    {
        //Debug.Log("PersistentDataPath: "+Application.persistentDataPath);

        Loading loading = loadingManager.AddALoading(0);

        bool checkFile = false;

        if (checkFile = File.Exists(pathAndURL.localProjectAssetBundlesInfoPath))
        {
            string log = "有本地ProjectAssetBundlesInfo.txt";
            GlobalDebug.Addline(log);
            Debug.Log(log);

            string jsonStr = File.ReadAllText(pathAndURL.localProjectAssetBundlesInfoPath);
            localProjectAssetBundlesInfo = JsonUtility.FromJson <ProjectAssetBundlesInfo>(jsonStr);

            Debug.Log(pathAndURL.serverProjectAssetBundlesInfoPath);
            GlobalDebug.Addline(pathAndURL.serverProjectAssetBundlesInfoPath);

            Debug.Log(netCtrlManager);

            //"?"+DateTime.Now.ToString() 添加时间防止ios读取http缓存
            netCtrlManager.WebRequest(
                "同步AssetBundle服务器",
                pathAndURL.serverProjectAssetBundlesInfoPath + "?" + DateTime.Now.ToString(),
                loading.LoadingAnimation,
                (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.Log("ServerProjectAssetBundlesInfo Load Failed!"); },
                (DownloadHandler t) =>
            {
                serverProjectAssetBundlesInfo = JsonUtility.FromJson <ProjectAssetBundlesInfo>(t.text);
                //                  if (globalDebug)
                GlobalDebug.ReplaceLine(t.text, 15);
                Debug.Log(t.text);

                string log2 = "ServerTime:" + serverProjectAssetBundlesInfo.buildTime + " LocalTime:" + localProjectAssetBundlesInfo.buildTime;
                GlobalDebug.Addline(log2);
                Debug.Log(log2);

                //判断两个资源的生成时间,如果时间不一样表示资源以过期,要删去旧的资源以便重新下载
                if (serverProjectAssetBundlesInfo.buildTime != localProjectAssetBundlesInfo.buildTime)
                {
                    string log3 = "删除老资源,替换新资源";
                    GlobalDebug.Addline(log3);
                    Debug.Log(log3);

                    File.WriteAllText(pathAndURL.localProjectAssetBundlesInfoPath, t.text);
                    for (int i = 0; i < serverProjectAssetBundlesInfo.sceneAssetBundle.Length; i++)
                    {
                        Caching.ClearOtherCachedVersions(pathAndURL.projectPath + serverProjectAssetBundlesInfo.sceneAssetBundle[i], Hash128.Parse(serverProjectAssetBundlesInfo.sceneAssetBundleHash[i]));
                    }
                }

                if (OnCached != null)
                {
                    OnCached.Invoke(serverProjectAssetBundlesInfo, inProjectID, hxAssetBundleName);
                }
                else
                {
                    StartLoadAssetBundle(serverProjectAssetBundlesInfo);
                }
            },
                null,
                null
                );
        }
        else
        {
            string log = "无本地ProjectAssetBundlesInfo.txt";
            GlobalDebug.Addline(log);
            Debug.Log(log);

            netCtrlManager.WebRequest(
                "同步AssetBundle服务器",
                pathAndURL.serverProjectAssetBundlesInfoPath,
                loading.LoadingAnimation,
                (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.Log("ServerProjectAssetBundlesInfo Load Failed!"); },
                (DownloadHandler t) =>
            {
                string log2 = "获取到Server的ProjectAssetBundlesInfo.txt";
                GlobalDebug.Addline(log2);
                Debug.Log(log2);

                GlobalDebug.ReplaceLine(t.text, 15);

                serverProjectAssetBundlesInfo = JsonUtility.FromJson <ProjectAssetBundlesInfo>(t.text);
                File.WriteAllText(pathAndURL.localProjectAssetBundlesInfoPath, t.text);

                if (OnCached != null)
                {
                    OnCached.Invoke(serverProjectAssetBundlesInfo, inProjectID, hxAssetBundleName);
                }
                else
                {
                    StartLoadAssetBundle(serverProjectAssetBundlesInfo);
                }
            },
                null,
                null
                );
        }

        //  if(globalDebug)
        GlobalDebug.ReplaceLine("HasLoaclInfo.txt:" + checkFile.ToString(), 16);
    }