Ejemplo n.º 1
0
    void SearchAllSource()
    {
        renderVertexCount   = 0;
        renderTriFaceCount  = 0;
        rawdataVertexCount  = 0;
        rawdataTriFaceCount = 0;

        allMesh      = new List <Mesh>();
        allMaterials = new List <Material>();

        allGameObject3DMesh        = new List <Object3DMesh>();
        allCustomTexture           = new List <Texture>();
        allLightmapTexture         = new List <Texture>();
        allCubeMapTexture          = new List <Cubemap>();
        allGameObject3DTexture     = new List <Object3DTexture>();
        allGameObject3DCubeTexture = new List <Object3DCubeTexture>();


        if (envCubeMap == null)
        {
            string log = gameObject.name + "的envCubeMap贴图没设置!";
            GlobalDebug.Addline(log);
            Debug.Log(log);
            Debug.LogWarning(log);
            Debug.LogError(log);
            return;
        }

        //默认环境贴图,第一张图为天空图
        allCubeMapTexture.Add(envCubeMap);
        allGameObject3DCubeTexture.Add(new Object3DCubeTexture((Cubemap)envCubeMap, "@_CubeMap"));


        ///得到当前Unity3d场景烘培出来的Lightmap
        ///
        for (int i = 0; i < LightmapSettings.lightmaps.Length; i++)
        {
            if (LightmapSettings.lightmaps[i].lightmapColor != null)
            {
                allLightmapTexture.Add(LightmapSettings.lightmaps[i].lightmapColor);
            }
        }


        for (int i = 0; i < allTempObject3DInfo.Count; i++)
        {
            if (allTempObject3DInfo[i].mesh != null)
            {
                renderVertexCount  += allTempObject3DInfo[i].vertexCount;
                renderTriFaceCount += allTempObject3DInfo[i].triFaceCount;
                Material[] tempMats;
                if (allTempObject3DInfo[i].isInstance3DGameObject)
                {
                    tempMats = allTempObject3DInfo[i].mats;
                }
                else
                {
                    tempMats = allTempObject3DInfo[i].GetComponent <MeshRenderer>().sharedMaterials;
                }

                int matCount = tempMats.Length;
                for (int j = 0; j < matCount; j++)
                {
                    if (!allMaterials.Contains(tempMats[j]))
                    {
                        allMaterials.Add(tempMats[j]);
                    }
                }

                ///首次添加mesh,且记录mesh的拥有者
                if (!allMesh.Contains(allTempObject3DInfo[i].mesh))
                {
                    rawdataVertexCount  += allTempObject3DInfo[i].vertexCount;
                    rawdataTriFaceCount += allTempObject3DInfo[i].triFaceCount;
                    allMesh.Add(allTempObject3DInfo[i].mesh);
                    allGameObject3DMesh.Add(new Object3DMesh(allTempObject3DInfo[i].mesh, allTempObject3DInfo[i].transform, allTempObject3DInfo[i].objectId.ToString(), allTempObject3DInfo[i].exportUV, allTempObject3DInfo[i].exportUV2, allTempObject3DInfo[i].useRealtimeLight, allTempObject3DInfo[i].useVertexColorLightmap, allTempObject3DInfo[i].hasSpriteTreeMat, allTempObject3DInfo[i].hasWaterMat));
                }
                else
                {
                    for (int j = 0; j < allGameObject3DMesh.Count; j++)
                    {
                        //再次添拥有者
                        if (allTempObject3DInfo[i].mesh == allGameObject3DMesh[j].mesh)
                        {
                            allGameObject3DMesh[j].InsertOne(allTempObject3DInfo[i].transform, allTempObject3DInfo[i].objectId.ToString(), allTempObject3DInfo[i].hasSpriteTreeMat, allTempObject3DInfo[i].hasWaterMat);
                        }
                    }
                }
            }
        }



        allGameObject3DCount = allTempObject3DInfo.Count;
        meshCount            = allGameObject3DMesh.Count;

        for (int j = 0; j < allMaterials.Count; j++)
        {
            Texture mainTex   = new Texture();
            Texture lightMap  = new Texture();
            Texture cubeMap   = new Texture();
            Texture normalMap = new Texture();



            if (allMaterials[j].GetTexture("_MainTex") != null)
            {
                mainTex = allMaterials[j].GetTexture("_MainTex");
            }

            if (allMaterials[j].HasProperty("_LightMap") && allMaterials[j].GetTexture("_LightMap") != null)
            {
                lightMap = allMaterials[j].GetTexture("_LightMap");
            }

            if (allMaterials[j].HasProperty("_CubeMap") && allMaterials[j].GetTexture("_CubeMap") != null)
            {
                cubeMap = allMaterials[j].GetTexture("_CubeMap");
            }

            if (allMaterials[j].HasProperty("_BumpMap") && allMaterials[j].GetTexture("_BumpMap") != null)
            {
                normalMap = allMaterials[j].GetTexture("_BumpMap");
            }

            if (mainTex != null && !allCustomTexture.Contains(mainTex))
            {
                allCustomTexture.Add(mainTex);
                allGameObject3DTexture.Add(new Object3DTexture(mainTex, allMaterials[j].name + "@_MainTex"));
            }
            else if (mainTex != null)
            {
                for (int k = 0; k < allGameObject3DTexture.Count; k++)
                {
                    if (mainTex == allGameObject3DTexture[k].tex)
                    {
                        allGameObject3DTexture[k].InsertOne(allMaterials[j].name + "@_MainTex");
                    }
                }
            }

            if (lightMap != null && !allCustomTexture.Contains(lightMap))
            {
                allCustomTexture.Add(lightMap);
                allGameObject3DTexture.Add(new Object3DTexture(lightMap, allMaterials[j].name + "@_LightMap"));
            }
            else if (lightMap != null)
            {
                for (int k = 0; k < allGameObject3DTexture.Count; k++)
                {
                    if (lightMap == allGameObject3DTexture[k].tex)
                    {
                        allGameObject3DTexture[k].InsertOne(allMaterials[j].name + "@_LightMap");
                    }
                }
            }

            if (cubeMap != null && !allCubeMapTexture.Contains((Cubemap)cubeMap))
            {
                allCubeMapTexture.Add((Cubemap)cubeMap);
                allGameObject3DCubeTexture.Add(new Object3DCubeTexture((Cubemap)cubeMap, allMaterials[j].name + "@_CubeMap"));
            }
            else if (cubeMap != null)
            {
                for (int k = 0; k < allGameObject3DCubeTexture.Count; k++)
                {
                    if (cubeMap == allGameObject3DCubeTexture[k].tex)
                    {
                        allGameObject3DCubeTexture[k].InsertOne(allMaterials[j].name + "@_CubeMap");
                    }
                }
            }


            if (normalMap != null && !allCustomTexture.Contains(normalMap))
            {
                allCustomTexture.Add(normalMap);
                allGameObject3DTexture.Add(new Object3DTexture(normalMap, allMaterials[j].name + "@_BumpMap"));
            }
            else if (normalMap != null)
            {
                for (int k = 0; k < allGameObject3DTexture.Count; k++)
                {
                    if (normalMap == allGameObject3DTexture[k].tex)
                    {
                        allGameObject3DTexture[k].InsertOne(allMaterials[j].name + "@_BumpMap");
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    string RecordInteractiveActionInfo(InteractiveAction inAct)
    {
        if (inAct.needDisplayRoot != null && inAct.needDisplayRoot.GetComponent <DontExport>() != null)
        {
            string log = inAct.needDisplayRoot.name + "被用在needDisplayRoot,且又含有DontExport";
            GlobalDebug.Addline(log);
            Debug.Log(log);
            Debug.LogWarning(log);
            Debug.LogError(log);

            return("");
        }


        string jsonString = "{";

        //取得自定义的objectid
        jsonString += "\"gameObjectName\":\"" + (inAct.needDisplayRoot != null ? GetUTF16_2(inAct.needDisplayRoot.name) : "") + "\"";
        jsonString += ",\"needDisplayRoot\":" + (inAct.needDisplayRoot != null ? inAct.needDisplayRoot.GetComponent <Object3DInfo>().objectId:-1);

        jsonString += ",\"needSetCameraName\":\"" + (inAct.cameraUniversal != null?inAct.cameraUniversal.name + "\"":"\"");

        if (inAct.cameraUniversal != null)
        {
            string[] splitString = inAct.cameraStates.Split(',');
            if (splitString.Length != 6)
            {
                string log = inAct.ToString() + "CameraStates格式设置有错误!";
                GlobalDebug.Addline(log);
                Debug.Log(log);
                Debug.LogWarning(log);
                Debug.LogError(log);
                return("");
            }

            if (splitString[2] != "")
            {
                float zFloatTemp = float.Parse(splitString[2]);
                zFloatTemp     = -zFloatTemp;
                splitString[2] = zFloatTemp.ToString();
            }

//            if (splitString[5] != "")
//                splitString[5] = "-" + splitString[5];

            jsonString += ",\"cameraStates\":[";
            jsonString += "\"" + splitString[0] + "\",";
            jsonString += "\"" + splitString[1] + "\",";
            jsonString += "\"" + splitString[2] + "\",";
            jsonString += "\"" + splitString[3] + "\",";
            jsonString += "\"" + splitString[4] + "\",";
            jsonString += "\"" + splitString[5] + "\"]";
        }
        else
        {
            jsonString += ",\"cameraStates\":[]";
        }

        if (inAct.pzMesh != null)
        {
            jsonString += ",\"pzMesh\":" + GetCollisonMeshJson(inAct.pzMesh);
        }

        jsonString += "}";

        return(jsonString);
    }
Ejemplo n.º 3
0
    void LoopAdditiveScene(bool loadImageInEnd = true)
    {
        //是否需要打断加载
        if (needBreakLoad)
        {
            GlobalDebug.Addline("Break Add Scene");
            Debug.Log("Break Add Scene");
            unload.LoadUnloadScene();
            return;
        }


        currentAddSceneID++;

        if (currentAddSceneID < assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath.Length)
        {
            /*
             * Loading loadingScene = loadingManager.AddALoading(4);
             * loadingScene.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[currentAddSceneID], LoadSceneMode.Additive), "正在加载");
             * loadingScene.OnLoadedEvent.AddListener(() => { LoopAdditiveScene(); });
             */
            if (assetBundleManager.serverProjectAssetBundlesInfo.sceneTypeSet != null && assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath.Length == assetBundleManager.serverProjectAssetBundlesInfo.sceneTypeSet.Length)
            {
                if (assetBundleManager.serverProjectAssetBundlesInfo.sceneTypeSet[currentAddSceneID] == 8)
                {
                    Debug.Log("跳过360场景 " + assetBundleManager.serverProjectAssetBundlesInfo.sceneAssetBundle[currentAddSceneID]);
                    //跳过360场景,开始加载下个场景
                    LoopAdditiveScene();
                }
                else
                {
                    Loading loadingScene = loadingManager.AddALoading(4);
                    loadingScene.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[currentAddSceneID], LoadSceneMode.Additive), "正在加载");
                    loadingScene.OnLoadedEvent.AddListener(() => { LoopAdditiveScene(); });
                }
            }
            else
            {
                Loading loadingScene = loadingManager.AddALoading(4);
                loadingScene.LoadingAnimation(SceneManager.LoadSceneAsync(assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath[currentAddSceneID], LoadSceneMode.Additive), "正在加载");
                loadingScene.OnLoadedEvent.AddListener(() => { LoopAdditiveScene(); });
            }
        }
        else if (currentAddSceneID == assetBundleManager.serverProjectAssetBundlesInfo.needExportScenePath.Length)
        {
            GlobalDebug.Addline("All Additive Scene Loaded!");
            Debug.Log("All Additive Scene Loaded!");

            //已完成循环加载场景
            isLoopingAddSource = false;

            if (loadImageInEnd)
            {
                //如果还要下载图片
                isLoopingAddSource = true;
                imageCache.LoopLoadAndCacheImageFromServer();
            }

            if (appBridge.appProjectInfo.sceneLoadMode == "2")
            {
                defaultGUI.mainBtnGroup.GetComponent <ButtonGroup>().imageButtonGroup[4].SetBtnState(true, 0);
            }

            if (onLoadDone != null)
            {
                onLoadDone.Invoke("OnLoadDone");
            }


            appBridge.Unity2App("unityLoadDone");
            appBridge.Unity2App("unityReady");

            Debug.Log("unityLoadDone");
            GlobalDebug.Addline("unityLoadDone");
        }
    }
Ejemplo n.º 4
0
    //如果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);
    }
Ejemplo n.º 5
0
    string RecordCameraCenterInfo(CameraUniversalCenter cameraUniversalCenter)
    {
        string jsonString = "\"cameraUniversalCenter\":{";

        jsonString += "\"initialCameraName\":\"" + cameraUniversalCenter.currentCamera.name + "\"";
        jsonString += ",\"cameras\":{";

        for (int i = 0; i < cameraUniversalCenter.cameras.Count; i++)
        {
            CameraUniversal cameraUniversal = cameraUniversalCenter.cameras[i].GetComponent <CameraUniversal>();

            if (cameraUniversal == null)
            {
                string log = cameraUniversalCenter.cameras[i].transform.name + "没有CameraUniversal脚本!";
                GlobalDebug.Addline(log);
                Debug.Log(log);
                Debug.LogWarning(log);
                Debug.LogError(log);
            }

//            jsonString += "{";
            jsonString += "\"" + cameraUniversalCenter.cameras[i].gameObject.name + "\":";
            jsonString += "{";
            jsonString += "\"fieldOfView\":" + cameraUniversalCenter.cameras[i].GetComponent <Camera>().fieldOfView;
            jsonString += ",\"nearClip\":" + cameraUniversalCenter.cameras[i].GetComponent <Camera>().nearClipPlane;
            jsonString += ",\"farClip\":" + cameraUniversalCenter.cameras[i].GetComponent <Camera>().farClipPlane;

            jsonString += ",\"cameraStates\":[" + cameraUniversal.camBase.transform.position.x + ",";
            jsonString += cameraUniversal.camBase.transform.position.y + ",";
            jsonString += -cameraUniversal.camBase.transform.position.z + ",";
            jsonString += cameraUniversal.Xcount + ",";
            jsonString += cameraUniversal.Ycount + ",";

            //i==0为鸟瞰相机,鸟瞰相机多加3米远
            float zFinal = cameraUniversal.Zcount;
            if (i == 0)
            {
                zFinal += 3;
            }
            jsonString += zFinal + ",";

            Vector3 lookAt = new Vector3(0, 0, 0);

/*
 *          if (GetCameraType(cameraUniversalCenter.cameras[i]) == 1)
 *          {
 *              lookAt = cameraUniversal.GetComponent<SpaceCamera>().spaceLookAtObject.transform.position;
 * //                Debug.Log(lookAt);
 *              lookAt.z = -lookAt.z;
 *              Debug.Log(lookAt);
 *          }
 */
            jsonString += lookAt.x + ",";
            jsonString += lookAt.y + ",";
            jsonString += lookAt.z + ",";

            jsonString += cameraUniversal.minimumX + ",";
            jsonString += cameraUniversal.maximumX + ",";

            jsonString += cameraUniversal.minimumZ + ",";
            jsonString += cameraUniversal.maximumZ + ",";
            jsonString += cameraUniversal.zhiBeiZhenCorrect;

            jsonString += "]}";

            if (i != cameraUniversalCenter.cameras.Count - 1)
            {
                jsonString += ",";
            }
        }

        jsonString += "}}";

        return(jsonString);
    }
Ejemplo n.º 6
0
    void ProcessMessage(RemoteGather.RemoteMessage p)
    {
        switch (p.messageType)
        {
        //CameraStateMessage
        case 49:

            string log = "Process CameraStateMessage";
            Debug.Log(log);
            GlobalDebug.Addline(log, true);

            /*
             * foreach (float f in p.cameraStates)
             * {
             *  Debug.Log(f);
             * }
             */
            RemoteGather.currentCameraUniversal.SetCameraPositionAndXYZCount(p.cameraStates);
            RemoteGather.needProcessMessages.Remove(p);
            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(72).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(72));

            break;

        //BtnCtrlMessage
        case 50:
            string log2 = "Process BtnCtrlMessage";
            Debug.Log(log2);
            GlobalDebug.Addline(log2, true);

            RemoteGather.ProcessRemoteMessage(p.btnName, p.btnState == 65);
            RemoteGather.needProcessMessages.Remove(p);

            log2 = "Btn事件还有:" + RemoteGather.needSendBtnCtrlMessages.Count;
            Debug.Log(log2);
            GlobalDebug.Addline(log2);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(73).GetBytesData(), false);
//              RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(73));

            break;

        //AreYouReadyMessage
        case 51:
            string log3 = "Process AreYouReady Message";
            Debug.Log(log3);
            GlobalDebug.Addline(log3, true);

            isOtherSideOnline = true;
            RemoteGather.needProcessMessages.Remove(p);



            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(74).GetBytesData(), false);
//                RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));
            break;

        //ScaleImageMessage
        case 52:
            string log4 = "Process ScaleImage Message";
            Debug.Log(log4);
            GlobalDebug.Addline(log4, true);

            isOtherSideOnline = true;

//              Debug.Log(p.btnName);

            RemoteGather.allScaleImage[p.btnName].SetState(p.scaleImageStates);
            RemoteGather.needProcessMessages.Remove(p);

            //Send Ack
            SendCtrlMessage(new RemoteGather.RemoteMessage(75).GetBytesData(), false);
            //                RemoteGather.needSendAckMessages.Add(new RemoteGather.RemoteMessage(74));
            break;

        //对方断开连接

        case 106:
            string log5 = "Receive 对方主动断开连接";
            Debug.Log(log5);
            GlobalDebug.Addline(log5, true);
            isOtherSideOnline = false;
            RemoteGather.needProcessMessages.Remove(p);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 7
0
    public void DisplayUI(string state)
    {
        switch (state)
        {
        case "0":
            defaultGUIRoot.AlphaPlayBackward();
            break;

        case "1":
            defaultGUIRoot.AlphaPlayForward();
            isPortraitUI = false;

//                triggerMusic.AlphaPlayForward();
            leftWarning.AlphaPlayBackward();
            rightWarning.AlphaPlayForward();
            mainBtnGroup.AlphaPlayForward();
            triggerHXList.AlphaPlayForward();
            triggerXFGroup.AlphaPlayForward();
            triggerBackBtn.AlphaPlayForward();
            triggerExit.AlphaPlayForward();
            triggerVRBtn.AlphaPlayForward();
            triggerShare.AlphaPlayForward();
            triggerEnterFangJianPortrait.AlphaPlayBackward();
            //设置卡通角色
            CartoonPlayer.hasInit = true;
            sceneInteractiveManger.PlayCartoonAni();

            //在线讲盘设置,在线讲盘
            if (appBridge.appProjectInfo.sceneLoadMode == "9")
            {
                triggerExit.AlphaPlayBackward();
                triggerVRBtn.AlphaPlayBackward();
                triggerShare.AlphaPlayBackward();
                AppBridge.isInRemoteState = true;
            }

            break;

        case "2":
            defaultGUIRoot.AlphaPlayForward();
            isPortraitUI = true;

            leftWarning.AlphaPlayForward();
            rightWarning.AlphaPlayBackward();
            mainBtnGroup.AlphaPlayBackward();
            triggerHXList.AlphaPlayBackward();
            triggerXFGroup.AlphaPlayBackward();
            triggerBackBtn.AlphaPlayBackward();
            triggerExit.AlphaPlayBackward();
            triggerVRBtn.AlphaPlayBackward();
            triggerShare.AlphaPlayBackward();
            triggerEnterFangJianPortrait.AlphaPlayForward();
//                triggerMusic.AlphaPlayBackward();

            //设置卡通角色
            CartoonPlayer.hasInit = false;
            sceneInteractiveManger.CloseCartoonAni();

            break;
        }
//     appBridege.Unity2App("DisplayUI");
        Debug.Log("DisplayUI " + state);
        GlobalDebug.Addline("DisplayUI " + state);
    }
Ejemplo n.º 8
0
    //以下函数为,外部调用Unity函数
    void Load(string info)
    {
        GlobalDebug.Addline("APP2Unity ReceiveInfo:" + info);
        Debug.Log("APP2Unity ReceiveInfo:" + info);

        appProjectInfo = JsonUtility.FromJson <AppProjectInfo>(info);

        string[] ipS = appProjectInfo.remoteServer.Split('.');
        if (ipS.Length == 4)
        {
            byte[] ipBytes = new byte[] { (byte)int.Parse(ipS[0]), (byte)int.Parse(ipS[1]), (byte)int.Parse(ipS[2]), (byte)int.Parse(ipS[3]) };
            MFQTcpClient.remoteIPAddress = new System.Net.IPAddress(ipBytes);
        }
        else
        {
            Debug.LogError("RemoteServerIPAdressError!");
        }

        int remoteUserIDLength = appProjectInfo.remoteUserID.Length;
        int userIDLenght       = appProjectInfo.userID.Length;

        //必须使用10位长度,才能正确建立房间
        if (remoteUserIDLength > 10)
        {
            appProjectInfo.remoteUserID = appProjectInfo.remoteUserID.Substring(remoteUserIDLength - 10, 10);
        }

        if (userIDLenght > 10)
        {
            appProjectInfo.userID = appProjectInfo.userID.Substring(userIDLenght - 10, 10);
        }

        if (remoteUserIDLength < 10)
        {
            //Debug.Log(remoteUserIDLength);
            appProjectInfo.remoteUserID = appProjectInfo.remoteUserID.PadLeft(10, '0');
        }

        if (userIDLenght < 10)
        {
            //Debug.Log(remoteUserIDLength);
            appProjectInfo.userID = appProjectInfo.userID.PadLeft(10, '0');
        }

        appProjectInfo.userID = appProjectInfo.userID.Remove(0, 1).PadLeft(10, '0');

        if (appProjectInfo.userType == "1")
        {
            remoteManger.runAtType      = RemoteManger.RunAtType.Master;
            appProjectInfo.remoteUserID = appProjectInfo.userID.Substring(4, 6).PadLeft(10, '0');
        }
        else if (appProjectInfo.userType == "2")
        {
            remoteManger.runAtType      = RemoteManger.RunAtType.Slave;
            appProjectInfo.remoteUserID = appProjectInfo.remoteUserID.Substring(4, 6).PadLeft(10, '0');
        }
        remoteManger.userID   = appProjectInfo.userID;
        remoteManger.remoteID = appProjectInfo.remoteUserID;

        serverProjectInfo.LoadServerProjectInfo(appProjectInfo.dataServer, appProjectInfo.dataServer, appProjectInfo.projectID, appProjectInfo.sceneLoadMode);
    }
Ejemplo n.º 9
0
 void Roads()
 {
     GlobalDebug.Addline("APP2Unity Roads");
     Debug.Log("APP2Unity Roads");
     defaultGUI.mainBtnGroup.GetComponent <ButtonGroup>().imageButtonGroup[3].SetBtnState(true, 0);
 }
Ejemplo n.º 10
0
    public void EnterHuXing()
    {
        appBridge.Unity2App("unityOpenRoomType", currentSelectHuXingType.huXingID);
        Debug.Log("unityOpenRoomType:" + currentSelectHuXingType.huXingID);
        GlobalDebug.Addline("unityOpenRoomType:" + currentSelectHuXingType.huXingID);

        sceneInteractiveManger.RenderSenceThumbnail(sceneInteractiveManger.thumbnailOutdoor, hxfbScene, hxfbScene.cameraUniversalCenter.currentCamera, hxfbCameraArgs);

        Debug.Log(hxfbCameraArgs);

        hxScene = sceneInteractiveManger.GetHuXingTypeInteractiveInfo(currentSelectHuXingType.hxName);

        hxScene.huXingType.hxMeshRoot.position    = hxScene.huXingType.hxNKWorldPos;
        hxScene.huXingType.hxMeshRoot.eulerAngles = new Vector3(0, hxScene.huXingType.rotOffset, 0);
        hxScene.huXingType.hxMeshRoot.gameObject.SetActive(true);

        //选房操作初始化预设
        if (sceneInteractiveManger.mainSenceInteractiveInfo != null && sceneInteractiveManger.mainSenceInteractiveInfo.louPanManager != null)
        {
            sceneInteractiveManger.mainSenceInteractiveInfo.louPanManager.GetSelectHuXinginstance(hxScene.huXingType.hxName);
            xfGUI.EnterHuXing();
        }

        triggerMusicBtn.AlphaPlayBackward();
        triggerFCZ.AlphaPlayForward();
        triggerShare.AlphaPlayForward();
        triggerHuXingThumbnail.AlphaPlayBackward();
        xfGUI.triggerOutDoorThumbnail.AlphaPlayForward();

        huXingCameraBG.transform.parent        = hxScene.cameraUniversalCenter.cameras[0].transform;
        huXingCameraBG.transform.localPosition = new Vector3(0, 0, 90);
        huXingCameraBG.transform.rotation      = new Quaternion();
        huXingCameraBG.transform.localScale    = new Vector3(250, 140, 1);

        sceneInteractiveManger.ChangeInteractiveScene(hxScene, false);

        DisplayHuXingFloorScrollMenu();

        xfGUI.SetHXSceneAndHXFBScene(hxScene, hxfbScene);

        //音频角色动画

/*
 *      if (hxScene.huXingType.hxAudioClip != null)
 *      {
 *          triggerCartoonAni.AlphaPlayForward();
 *          cartoonPlayer.OpenCartoonPeopleUseAudioFile(hxScene.huXingType.hxAudioClip, hxScene.huXingType.cartoonType);
 *
 *          if (hxScene.huXingType.hasPlayed)
 *          {
 *              cartoonPauseBtn.SetBtnState(true, 0);
 *          }
 *
 *          hxScene.huXingType.hasPlayed = true;
 *      }
 */

        appBridge.Unity2App("unityOpenRoomTypeDone");
        Debug.Log("unityOpenRoomTypeDone");
        GlobalDebug.Addline("unityOpenRoomTypeDone");
    }
Ejemplo n.º 11
0
 public void ShareRoom()
 {
     appBridge.Unity2App("unityShareRoom", currentSelectHuXingType.huXingID.ToString());
     Debug.Log("unityShareRoom");
     GlobalDebug.Addline("unityShareRoom");
 }
Ejemplo n.º 12
0
    private static extern void unityBackRoomTypeDone();// 户型返回完毕

//    [DllImport("__Internal")]
//    private static extern void unityEnterMYInPortraitDone();//竖屏进入户型漫游

    //unityOpenRoomType(string roomID)    进入户型
#endif
#endif

    //Unity调用外部代码
    public void Unity2App(string methodName, params object[] args)
    {
#if UNITY_ANDROID
        try
        {
            AndroidJavaClass  jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity");
            jo.Call(methodName, args);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }
#endif

#if true
#endif


#if !TEST
#if UNITY_IOS
        switch (methodName)
        {
        case "unityReady":
            unityReady();
            break;

        case "unityProtrait":
            unityProtrait();
            break;

        case "unityLandscape":
            unityLandscape();
            break;

        case "unityLoadDone":
            unityLoadDone();
            break;

        case "unityCloseRemote":
            unityCloseRemote((string)args[0]);
            break;

        case "unityShareRoom":
            unityShareRoom((string)args[0]);
            break;

        case "unityUnloadDone":
            unityUnloadDone();
            break;

        case "unityOpenRoomTypeDone":
            unityOpenRoomTypeDone();
            break;

        case "unityBackRoomTypeDone":
            unityBackRoomTypeDone();
            break;

//              case "unityEnterMYInPortraitDone":
//                  unityEnterMYInPortraitDone();
//                  break;
        default:
            GlobalDebug.Addline("未定义的方法:" + methodName);
            break;
        }
#endif
#endif
    }
Ejemplo n.º 13
0
 void Portrait()
 {
     GlobalDebug.Addline("APP2Unity Portrait");
     Debug.Log("APP2Unity Portrait");
     defaultGUI.Portrait();
 }
Ejemplo n.º 14
0
 void Landscape()
 {
     GlobalDebug.Addline("APP2Unity Landscape");
     Debug.Log("APP2Unity Landscape");
     defaultGUI.Landscape();
 }
Ejemplo n.º 15
0
    void PrcessProjectInfo(ProjectRootInfo inProjectRootInfo, bool isLoadFromCache = false)
    {
        //判断是否有外部全景图链接
        if (projectRootInfo.data.panoramaSwitch.isShow == 1)
        {
            Trigger_ToPanoramaBtn.AlphaPlayForward();
        }

        string log = "是否加载本地缓存ProjectInfo.txt:" + isLoadFromCache;

        GlobalDebug.Addline(log);
        Debug.Log(log);

        //声明信息
        if (inProjectRootInfo.data.declareSwitch == "1")
        {
            string[] infoGroup = inProjectRootInfo.data.declareContent.Split('#');
            if (infoGroup.Length == 2)
            {
                string infoFinal = infoGroup[0] + "\n" + infoGroup[1];
                warningLabel.text  = infoFinal;
                warningLabel2.text = infoFinal;
            }
        }
        else
        {
            warningLabel2.text = "";
        }

        proInfoTextTable.SetString(inProjectRootInfo.data.proName, inProjectRootInfo.data.proDiscr);



        imageCache.allNetTextrue2D = new List <NetTexture2D>();

        defaultGUI.quweiImagePlayer.netTexture2DGroup = new List <NetTexture2D>();

        for (int i = 0; i < inProjectRootInfo.data.qwInfo.Length; i++)
        {
            QwImage q = inProjectRootInfo.data.qwInfo[i];

            string modiferTime = q.modifyTime.Replace(" ", "").Replace("-", "").Replace(":", "");
            string qwImageUrl  = "downloadId=" + inProjectRootInfo.data.projectid + "&downloadType=10&mediaType=2&fileName=" + q.quweiImg;
            string qwImageName = modiferTime + q.quweiImg;

            List <NetTexture2D> tempFindGroup = imageCache.allNetTextrue2D.Where(n => n.texName == qwImageName).Select(n => n).ToList();

            if (tempFindGroup.Count == 0)
            {
                NetTexture2D temp = new NetTexture2D(qwImageName, qwImageUrl, imageCache);
                defaultGUI.quweiImagePlayer.netTexture2DGroup.Add(temp);
                imageCache.allNetTextrue2D.Add(temp);
            }
            else if (tempFindGroup.Count > 0)
            {
                defaultGUI.quweiImagePlayer.netTexture2DGroup.Add(tempFindGroup[0]);
            }
        }

        HXInfo[] hx = inProjectRootInfo.data.hxInfo;
        hxGUI.hxSceneHuXingTypeFinal = new HuXingType[hx.Length];

        for (int i = 0; i < hx.Length; i++)
        {
            hxGUI.hxSceneHuXingTypeFinal[i]                 = new HuXingType();
            hxGUI.hxSceneHuXingTypeFinal[i].hxName          = hx[i].modeName;
            hxGUI.hxSceneHuXingTypeFinal[i].viewDisplayMode = hx[i].mode3Ddisplay == null?"1":hx[i].mode3Ddisplay;
//            Debug.Log(hx[i].mode3Ddisplay);
            hxGUI.hxSceneHuXingTypeFinal[i].displayName = hx[i].display;
            //hxGUI.hxSceneHuXingTypeFinal[i].huXingID = hx[i].id;
            hxGUI.hxSceneHuXingTypeFinal[i].normalPrice  = -1;
            hxGUI.hxSceneHuXingTypeFinal[i].normalArea   = float.Parse(hx[i].area);
            hxGUI.hxSceneHuXingTypeFinal[i].fangXing     = hx[i].modeFormat;
            hxGUI.hxSceneHuXingTypeFinal[i].leiXing      = "";
            hxGUI.hxSceneHuXingTypeFinal[i].introduction = hx[i].discr;
            //hxGUI.hxSceneHuXingTypeFinal[i].pmtUrl = "";
            hxGUI.hxSceneHuXingTypeFinal[i].allFloor          = new HuXingType.floor[hx[i].floorData.Length];
            hxGUI.hxSceneHuXingTypeFinal[i].netTexture2DGroup = new List <NetTexture2D>();

            for (int j = 0; j < hxGUI.hxSceneHuXingTypeFinal[i].allFloor.Length; j++)
            {
                hxGUI.hxSceneHuXingTypeFinal[i].huXingID = hx[i].modeId;


//                Debug.Log(hx[i].floorData[j].modeFloor);
                //服务器上的modeFloor表示的意思是Unity中floorName的意思
                hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].floorName   = hx[i].floorData[j].modeFloor;
                hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].displayName = hx[i].floorData[j].floorName;

                string modiferTime = hx[i].floorData[j].modifyTime.Replace(" ", "").Replace("-", "").Replace(":", "");
                hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtUrl  = "downloadId=" + hx[i].floorData[j].modeId + "&downloadType=3&mediaType=2&fileName=" + hx[i].floorData[j].fileName;
                hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtName = modiferTime + hx[i].floorData[j].fileName;

                if (hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtName != "")
                {
//                  hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtName = "A" + (j+1) + ".jpg";
                    List <NetTexture2D> tempFindGroup = imageCache.allNetTextrue2D.Where(n => n.texName == hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtName).Select(n => n).ToList();

                    if (tempFindGroup.Count == 0)
                    {
                        //测试用
                        //NetTexture2D temp = new NetTexture2D("A" + (j + 1) + ".jpg", "A" + (j + 1) + ".jpg", imageCache);
                        //服务器用
                        NetTexture2D temp = new NetTexture2D(hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtName, hxGUI.hxSceneHuXingTypeFinal[i].allFloor[j].pmtUrl, imageCache);

                        hxGUI.hxSceneHuXingTypeFinal[i].netTexture2DGroup.Add(temp);
                        imageCache.allNetTextrue2D.Add(temp);
                    }
                    else if (tempFindGroup.Count > 0)
                    {
                        hxGUI.hxSceneHuXingTypeFinal[i].netTexture2DGroup.Add(tempFindGroup[0]);
                    }
                }
            }
        }

        if (isLoadFromCache)
        {
            assetBundleManager.serverProjectAssetBundlesInfo = JsonUtility.FromJson <ProjectAssetBundlesInfo>(File.ReadAllText(pathAndURL.localProjectAssetBundlesInfoPath));
            assetBundleManager.StartLoadAssetBundle(assetBundleManager.serverProjectAssetBundlesInfo);
        }
        else
        {
            onServerProjectInfoLoaded.Invoke(inProjectRootInfo.data.projectid);

//            assetBundleManager.LoadProjcetAssetBundles
        }
    }
Ejemplo n.º 16
0
 void DisplayCancelBtn()
 {
     defaultGUI.triggerCancelBtn.AlphaPlayForward();
     GlobalDebug.Addline("APP2Unity DisplayCancelBtn");
     Debug.Log("APP2Unity DisplayCancelBtn");
 }
Ejemplo n.º 17
0
    void CopyMessage(byte[] inHead, byte[] ctrlData)
    {
        string front = Encoding.UTF8.GetString(inHead, 0, 4);
        string back  = Encoding.UTF8.GetString(inHead, 4, 4);

        Debug.Log("Receive Head:" + front + ":" + back);
        GlobalDebug.Addline("Receive Head:" + front + ":" + back);
        //处理成功
        if (front == "9000")
        {
            switch (back)
            {
            case "1002":
                isEnterRoom = true;
                Debug.Log("成功连接服务器,等待对方上线");
                GlobalDebug.Addline("成功连接服务器,等待对方上线");
                remoteGUI.SetHelpInfoString("成功连接服务器,等待对方上线");

                isUseRemoteGather = true;
                waitingAck        = false;
                currentRetryCount = 0;
                break;

            default:
                break;
            }
        }//处理失败
        else if (front == "9001")
        {
            switch (back)
            {
            case "1002":
                isEnterRoom = true;
                Debug.Log("进入房间失败");
                GlobalDebug.Addline("进入房间失败");
                waitingAck        = false;
                currentRetryCount = 0;
                break;

            default:
                break;
            }
        }//收到信息
        else if (front == "1004")
        {
            lastMessageReceiveFromOtherSidePastTime = 0;

            RemoteGather.RemoteMessage rMessage = new RemoteGather.RemoteMessage();
            if (ctrlData.Length == 74)
            {
                rMessage = new RemoteGather.RemoteMessage(ctrlData);
            }
            else
            {
            }

            switch (back)
            {
            case "0000":
                string log;

                if (rMessage != null)
                {
//                        Debug.Log(rMessage.messageType);

                    switch (rMessage.messageType)
                    {
                    //不能在这里处理,因为该程序不再主线程下运行,将
                    case 49:
                    case 50:
                    case 51:
                    case 52:
                        RemoteGather.needProcessMessages.Add(rMessage);
                        break;

                    //Ack
                    case 72:

                        log = "Receive CameraStateMessage Ack";
                        Debug.Log(log);
                        GlobalDebug.Addline(log, true);

                        RemoteGather.lastSendCameraCameraState = cameraStateWhenSendMessage;

                        waitingAck        = false;
                        currentRetryCount = 0;
                        break;

                    //Ack
                    case 73:

                        log = "Receive BtnCtrlMessage Ack";
                        Debug.Log(log);
                        GlobalDebug.Addline(log, true);

                        RemoteGather.needSendBtnCtrlMessages.RemoveAt(0);
                        waitingAck        = false;
                        currentRetryCount = 0;
                        break;

                    //Ack
                    case 74:

                        log = "Receive AreYouReady Ack";
                        Debug.Log(log);
                        GlobalDebug.Addline(log, true);


                        isOtherSideOnline = true;
                        waitingAck        = false;
                        currentRetryCount = 0;
                        break;

                    //Ack
                    case 75:

                        log = "Receive ScaleImage Ack";
                        Debug.Log(log);
                        GlobalDebug.Addline(log, true);

                        RemoteGather.lastSendScaleImageState = scaleImageWhenSendMessage;
                        isOtherSideOnline = true;
                        waitingAck        = false;
                        currentRetryCount = 0;
                        break;

                    case 200:

                        log = "Receive 200 OK";
                        Debug.Log(log);
                        GlobalDebug.Addline(log);

                        //接到空消息
                        waitingAck = false;
                        break;
                    }
                }
                else
                {
                    //接到空消息
                    waitingAck = false;
                }

                break;

            default:
                break;
            }
        }//对方挂断
        else if (front == "1006")
        {
            string log = "Receive 1006 Head 对方主动退出";
            Debug.Log(log);
            GlobalDebug.Addline(log, true);

            RemoteGather.needProcessMessages.Add(new RemoteGather.RemoteMessage(106));
        }
        else
        {
            string log = "front 未知报头:" + front;
            GlobalDebug.Addline(log);
            Debug.Log(log);
            Debug.LogWarning(log);
            Debug.LogError(log);
        }
    }
Ejemplo n.º 18
0
    //Unity调用外部代码
    public void Unity2App(string methodName, params object[] args)
    {
#if UNITY_ANDROID
        try
        {
            AndroidJavaClass  jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity");
            jo.Call(methodName, args);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }
#endif

#if true
#endif


#if !TEST
#if UNITY_IOS && !UNITY_EDITOR
        switch (methodName)
        {
        case "unityReady":
            unityReady();
            break;

        case "unityChangeOrientationDone":
            unityChangeOrientationDone((string)args[0]);
            break;

        case "unityLoadDone":
            unityLoadDone();
            break;

        case "unityCloseRemote":
            unityCloseRemote((string)args[0]);
            break;

        case "unityShareRoom":
            unityShareRoom((string)args[0]);
            break;

        case "unityUnloadDone":
            unityUnloadDone();
            break;

        case "unityOpenRoomTypeDone":
            unityOpenRoomTypeDone();
            break;

        case "unityBackRoomTypeDone":
            unityBackRoomTypeDone();
            break;

        case "unityArRecoInfo":
            unityArRecoInfo((string)args[0]);
            break;

        case "unitySetMusic":
            unitySetMusic((string)args[0]);
            break;

        case "unityToPanorama":
            unityToPanorama((string)args[0]);
            break;

        case "unityCancelLoad":
            unityCancelLoad();
            break;

        case "unityExit":
            unityExit();
            break;

        case "unityNKLook":
            unityNKLook((string)args[0]);
            break;

        case "unityMYLook":
            unityMYLook((string)args[0]);
            break;

        case "unityVRState":
            unityVRState((string)args[0]);
            break;

        default:
            GlobalDebug.Addline("未定义的方法:" + methodName);
            break;
        }
#endif
#endif
    }
Ejemplo n.º 19
0
    void Update()
    {
        if (mfqTcpClient != null && mfqTcpClient.hasInit)
        {
            GlobalDebug.ReplaceLine("NeedProcessEvents: " + RemoteGather.needProcessMessages.Count.ToString(), 15);
            GlobalDebug.ReplaceLine("NeedSendEvents: " + RemoteGather.needSendBtnCtrlMessages.Count.ToString(), 16);

            GlobalDebug.ReplaceLine("IsEnterRoom: " + isEnterRoom.ToString(), 17);
            GlobalDebug.ReplaceLine("IsOtherSideOnline: " + isOtherSideOnline.ToString(), 18);
            GlobalDebug.ReplaceLine("waitingAck: " + waitingAck.ToString(), 19);



            if (sceneInteractiveManger.currentActiveSenceInteractiveInfo != null)
            {
                RemoteGather.currentCameraUniversal = sceneInteractiveManger.currentActiveSenceInteractiveInfo.cameraUniversalCenter.currentCamera;
            }



            //等待Ack
            if (waitingAck)
            {
                waitingAckPastTime += Time.deltaTime;

                if (waitingAckPastTime > maxTimeWaitAck)
                {
                    if (!isEnterRoom)
                    {
                        if (currentRetryCount < maxRetryCount)
                        {
                            string log = "重试进入房间次数:" + currentRetryCount;
                            GlobalDebug.Addline(log);
                            Debug.Log(log);

                            waitingAckPastTime = 0;
                            waitingAck         = false;
                            currentRetryCount  = 0;

                            DisConnect();
                            StartMFQTcpClient(runAtType, remoteID, userID);
                            EnterRoom();
                        }
                        else
                        {
                            string log = "重试进入房间达到最大次数,请检查网络连接!";
                            GlobalDebug.Addline(log);
                            Debug.Log(log);
                            Debug.LogWarning(log);
                            Debug.LogError(log);

                            waitingAckPastTime = 0;
                            waitingAck         = false;
                            currentRetryCount++;
//                          DisConnect();
                            LostConnect();
                        }
                    }//以下是操作传输重试
                    else
                    {
                        if (currentRetryCount < maxRetryCount)
                        {
                            waitingAckPastTime = 0;
                            waitingAck         = false;
                            currentRetryCount++;

                            string log = "重试发送信息次数:" + currentRetryCount;
                            GlobalDebug.Addline(log);
                            Debug.Log(log);
                        }
                        else
                        {
                            string log = "重试发送信息达到最大次数,准备重新连接讲盘网络!";
                            GlobalDebug.Addline(log);
                            Debug.Log(log);
                            Debug.LogWarning(log);
                            Debug.LogError(log);

                            waitingAck         = false;
                            waitingAckPastTime = 0;
                            currentRetryCount  = 0;
                            //断开连接重新尝试进入房间
                            DisConnect();
                            StartMFQTcpClient(runAtType, remoteID, userID);
                            EnterRoom();
                        }
                    }
                }
            }
            else if (isEnterRoom)
            {
                if (isOtherSideOnline)
                {
                    //判断10内有没有收到对方消息,如果没有收到消息,判定对方掉线重新发送AreYouReady消息;
                    lastMessageReceiveFromOtherSidePastTime += Time.deltaTime;
                    if (lastMessageReceiveFromOtherSidePastTime > 15)
                    {
                        isOtherSideOnline = false;
                    }
                }


                if (RemoteGather.needProcessMessages.Count > 0)
                {
                    ProcessMessage(RemoteGather.needProcessMessages[0]);
                } //判断对方是否在线,由slave每2秒进行发送验证消息,Master接收后确认Slave在线.Master开始发送当前状态.
                else if (!isOtherSideOnline)
                {
                    if (runAtType == RunAtType.Slave)
                    {
                        SendCtrlMessage(new RemoteGather.RemoteMessage(51).GetBytesData());
                        //设置成无限尝试
                        currentRetryCount = 0;
                        //起始时间设置为3秒,这样两秒后就能重试
                        waitingAckPastTime = 3;
                    }
                }//下面的if暂时没有使用上
                else if (isOtherSideOnline && RemoteGather.needSendAckMessages.Count > 0)
                {
                    SendCtrlMessage(RemoteGather.needSendAckMessages[0].GetBytesData(), false);
                    RemoteGather.needSendAckMessages.RemoveAt(0);
                }
                else if (isOtherSideOnline && runAtType == RunAtType.Master && RemoteGather.needSendBtnCtrlMessages.Count > 0)
                {
                    SendCtrlMessage(RemoteGather.needSendBtnCtrlMessages[0].GetBytesData());
                }
                else if (isOtherSideOnline && NeedSendCameraState())
                {
                    //目前的问题:在等待CameraState Ack的时候会收到对方的其它类型的信息,以至于没有收到CameraState Ack,一直处于等待Ack的状态.
                    //本想实现,master和slave相互之间的操作,有问题,先实现Master控制Slave
                    //
                    cameraStateWhenSendMessage = RemoteGather.currentCameraUniversal.GetCameraState();
                    SendCtrlMessage(new RemoteGather.RemoteMessage(49, "", false, RemoteGather.currentCameraUniversal).GetBytesData());
                }
                else if (isOtherSideOnline && NeedSendScaleImageState())
                {
                    scaleImageWhenSendMessage = RemoteGather.currentCtrlScaleImage.GetState();
                    SendCtrlMessage(new RemoteGather.RemoteMessage(52, RemoteGather.currentCtrlScaleImage.btnNameForRemote, false, null, RemoteGather.currentCtrlScaleImage).GetBytesData());
                }
            }
        }
    }
Ejemplo n.º 20
0
    public void RecordInfo()
    {
        senceInteractiveInfoJson = "{";

        if (cameraUniversalCenter != null && cameraUniversalCenter.currentCamera != null)
        {
            senceInteractiveInfoJson += RecordCameraCenterInfo(cameraUniversalCenter);
        }
        else
        {
            string log = gameObject.name + "cameraUniversalCenter未设置!";
            GlobalDebug.Addline(log);
            Debug.Log(log);
            Debug.LogWarning(log);
            Debug.LogError(log);
        }


        senceInteractiveInfoJson += ",";
        senceInteractiveInfoJson += "\"homeInAct\":";
        senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_Home);

        senceInteractiveInfoJson += ",";
        senceInteractiveInfoJson += "\"introInAct\":";
        senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_Intro);

        senceInteractiveInfoJson += ",";
        senceInteractiveInfoJson += "\"areaInAct\":";
        senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_Area);

        senceInteractiveInfoJson += ",";
        senceInteractiveInfoJson += "\"trafficInAct\":";
        senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_Traffic);

        senceInteractiveInfoJson += ",";
        senceInteractiveInfoJson += "\"supportsInAct\":";
        senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_Supports);


        if (f3d_HXFBGroup.Length > 0)
        {
            senceInteractiveInfoJson += ",";
            senceInteractiveInfoJson += "\"HXFBGroup\":[";

            for (int i = 0; i < f3d_HXFBGroup.Length; i++)
            {
                //               senceInteractiveInfoJson += "{\"";
                if (f3d_HXFBGroup[i].needDisplayRoot != null)
                {
//                  senceInteractiveInfoJson += f3d_HXFBGroup[i].needDisplayRoot.name + "\":";
                    senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_HXFBGroup[i]);
                }
                else
                {
                    string log = gameObject.name + "户型分布模型没有设置!";
                    GlobalDebug.Addline(log);
                    Debug.Log(log);
                    Debug.LogWarning(log);
                    Debug.LogError(log);
                }
//                senceInteractiveInfoJson += "}";
                if (i != f3d_HXFBGroup.Length - 1)
                {
                    senceInteractiveInfoJson += ",";
                }
            }

            senceInteractiveInfoJson += "]";
        }

        if (huXingType.allFloor.Length > 0)
        {
            huXingType.RecordEachFloorInteractiveAction();

            senceInteractiveInfoJson += ",";
            senceInteractiveInfoJson += "\"floorGroup\":[";

            for (int i = 0; i < huXingType.allFloor.Length; i++)
            {
                //                senceInteractiveInfoJson += "{";
                if (huXingType.allFloor[i].interactiveAction.needDisplayRoot != null)
                {
                    //                 senceInteractiveInfoJson += f3d_FloorGroup[i].needDisplayRoot.name + "\":";
                    senceInteractiveInfoJson += RecordInteractiveActionInfo(huXingType.allFloor[i].interactiveAction);
                }
                else
                {
                    string log = gameObject.name + "楼层模型没有设置!";
                    Debug.Log(log);
                    Debug.LogWarning(log);
                    Debug.LogError(log);
                }
                //               senceInteractiveInfoJson += "}";
                if (i != huXingType.allFloor.Length - 1)
                {
                    senceInteractiveInfoJson += ",";
                }
            }
            senceInteractiveInfoJson += "]";
        }



        /*
         *
         *      if (f3d_FloorGroup.Length > 0)
         *      {
         *          senceInteractiveInfoJson += ",";
         *          senceInteractiveInfoJson += "\"floorGroup\":[";
         *
         *          for (int i = 0; i < f3d_FloorGroup.Length; i++)
         *          {
         * //                senceInteractiveInfoJson += "{";
         *              if (f3d_FloorGroup[i].needDisplayRoot != null)
         *              {
         * //                    senceInteractiveInfoJson += f3d_FloorGroup[i].needDisplayRoot.name + "\":";
         *                  senceInteractiveInfoJson += RecordInteractiveActionInfo(f3d_FloorGroup[i]);
         *              }
         *              else
         *              {
         *                  string log = gameObject.name + "楼层模型没有设置!";
         *                  Debug.Log(log);
         *                  Debug.LogWarning(log);
         *                  Debug.LogError(log);
         *              }
         * //               senceInteractiveInfoJson += "}";
         *              if (i != f3d_FloorGroup.Length - 1)
         *              {
         *                  senceInteractiveInfoJson += ",";
         *              }
         *          }
         *          senceInteractiveInfoJson += "]";
         *
         *      }
         */
        senceInteractiveInfoJson += "}";
    }
Ejemplo n.º 21
0
    public void LoadProjcetAssetBundles(string inProjectID)
    {
//      Debug.Log("PersistentDataPath: "+Application.persistentDataPath);
//      SetProjectPath(inProjectID);

        Loading loading = loadingManager.AddALoading(0);

        bool checkFile = false;

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

            netCtrlManager.WebRequest(
                "同步服务器",
                pathAndURL.serverProjectAssetBundlesInfoPath,
                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);

                //判断两个资源的生成时间,如果时间不一样表示资源以过期,要删去旧的资源以便重新下载
                if (serverProjectAssetBundlesInfo.buildTime != localProjectAssetBundlesInfo.buildTime)
                {
                    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]));
                    }
                }

                StartLoadAssetBundle(serverProjectAssetBundlesInfo);
            },
                null,
                null
                );
        }
        else
        {
            netCtrlManager.WebRequest(
                "同步服务器",
                pathAndURL.serverProjectAssetBundlesInfoPath,
                loading.LoadingAnimation,
                (NetCtrlManager.RequestHandler r, UnityWebRequestAsyncOperation a, string info) => { Debug.Log("ServerProjectAssetBundlesInfo Load Failed!"); },
                (DownloadHandler t) =>
            {
//                   if (globalDebug)
                GlobalDebug.ReplaceLine(t.text, 15);

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

                StartLoadAssetBundle(serverProjectAssetBundlesInfo);
            },
                null,
                null
                );
        }

//  if(globalDebug)
        GlobalDebug.ReplaceLine("HasLoaclInfo.txt:" + checkFile.ToString(), 16);
    }
Ejemplo n.º 22
0
    void OnGUI()
    {
        if (senceHierarchyInfo != null && sceneAsset != null)
        {
            EditorGUI.LabelField(new Rect(20, 10, 1000, 20), new GUIContent("Web 输出:" + savePath));
        }

        if (lastSenceHierarchyInfo != senceHierarchyInfo)
        {
            lastSenceHierarchyInfo = senceHierarchyInfo;
            CheckOutPutPathNameAndCreateFolder();
        }

        if (lastSceneAsset != sceneAsset)
        {
            lastSceneAsset = sceneAsset;
            CheckOutPutPathNameAndCreateFolder();
        }



        senceHierarchyInfo = (SenceHierarchyInfo)EditorGUI.ObjectField(new Rect(20, 40, 300, 16), senceHierarchyInfo, typeof(SenceHierarchyInfo), true);
        sceneAsset         = (SceneAsset)EditorGUI.ObjectField(new Rect(20, 60, 300, 16), sceneAsset, typeof(SceneAsset), true);

/*
 *      savePath = EditorGUI.TextField(new Rect(20, 60, 280, 18), new GUIContent(""), savePath);
 *      if (GUI.Button(new Rect(320, 59, 150, 20), new GUIContent("Set Path (设置路径)")))
 *      {
 *          string temp = EditorUtility.OpenFolderPanel("Select ThreeJS folder", Application.dataPath, "threejsdata");
 *          if (temp != "")
 *          {
 *              savePath = temp;
 *              Debug.Log(savePath);
 *          }
 *      }
 */

        customTextrueMaxSize   = (TextrueSize)EditorGUI.EnumPopup(new Rect(170, 110, 300, 25), "贴图输出最大值", customTextrueMaxSize);
        lightmapTextrueMaxSize = (TextrueSize)EditorGUI.EnumPopup(new Rect(170, 150, 300, 25), "unity烘培贴图输出最大值", lightmapTextrueMaxSize);

        onlyHierarchyAndInteractiveinfo = EditorGUI.ToggleLeft(new Rect(170, 190, 300, 25), new GUIContent("只导出Hierarchy+Interactive.info"), onlyHierarchyAndInteractiveinfo);

        if (GUI.Button(new Rect(320, 250, 150, 20), new GUIContent("Export")))
        {
            CheckOutPutPathNameAndCreateFolder();

            if (senceHierarchyInfo != null)
            {
                //BuildAsset时忽略这个物体,这个物体只用在导出web资源,运行时不需要
                senceHierarchyInfo.gameObject.hideFlags = HideFlags.DontSaveInBuild;

                useCompress = true;

                //收集场景中所有需要导出的资源
                senceHierarchyInfo.PrepareThreeJsSceneData();

                //创建输出的文件夹
//              if (!onlyHierarchyAndInteractiveinfo)
//              CreateOutPutFold();

                //创建bin流,包含shader流
                if (!onlyHierarchyAndInteractiveinfo)
                {
                    CreateBuuferGeometryBinFile(senceHierarchyInfo);
                }
                else
                {
                    senceHierarchyInfo.allGameObject3DMesh = senceHierarchyInfo.lastAllGameObject3DMesh;
                }

                //创建场景信息
                CreateSenceHierarchyJsonFile(senceHierarchyInfo);

                //创建交互信息
                CreateSenceInteractiveJsonFile(senceHierarchyInfo);

                //复制出所有图片
                if (!onlyHierarchyAndInteractiveinfo)
                {
                    CopyAllTexture(senceHierarchyInfo);
                }

                //清除临时添加的ThreeJsObject3DInfo
                senceHierarchyInfo.DestroyTempData();
            }
            else
            {
                string log = "请选中SenceHierarchyInfo物体,如果场景中没有,请在根目录添加一个";
                GlobalDebug.Addline(log);
                Debug.Log(log);
                Debug.LogWarning(log);
                Debug.LogError(log);
            }
        }
    }