Esempio n. 1
0
    public void CloseVRGlass()
    {
        vrViewCanveGroupFade.AlphaPlayBackward();

        Input.gyro.enabled           = false;
        this.transform.parent        = globalManager;
        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
        moveUI.AlphaPlayBackward();
        zhunxUI.AlphaPlayBackward();

        leftEyeCamera.enabled  = false;
        rightEyeCamera.enabled = false;
//      cameraUniversal.GetComponent<Camera>().enabled = true;

        cameraUniversal.GetComponent <Camera>().cullingMask      = leftEyeCamera.cullingMask;
        cameraUniversal.GetComponent <Camera> ().clearFlags      = orginCameraClearFlags;
        cameraUniversal.GetComponent <Camera> ().backgroundColor = orginBackgroundColor;

        cameraUniversal.ResetCameraStateToInitial();
//      cameraUniversal.vrMoveForward = false;
        cameraUniversal = null;
        defaultGUI.AlphaPlayForward();
        appBridge.Unity2App("unityVRState", "0");
    }
Esempio n. 2
0
    /// <summary>
    /// 切换相机方式一,直接参数切换
    /// </summary>
    public void ChangeCamera(CameraUniversal targetCamera, float mTimeUseFly = 2)
    {
        AddCameraToGroup(targetCamera);

        if (targetCamera != null && targetCamera != currentCamera)
        {
            Debug.Log("ChangeCamera");
            lastCamera = currentCamera;

//          if (currentCamera == null)
//          currentCamera = targetCamera;

            if (currentCamera.playAnimationPath)
            {
                currentCamera.CameraPathStopPlay();
            }

            string currentState = currentCamera.DisableCamera();

            targetCamera.EnableCamera();

//          Vector3 toPos = targetCamera.transform.position;
//          Debug.Log(Vector3.Distance(toPos, lastCamera.transform.position));
//          Quaternion toRo = targetCamera.transform.localRotation;

            targetCamera.SetCameraPositionAndXYZCount(currentState, 0);
            targetCamera.DisableCameraCtrl();
            targetCamera.MoveToInitPosition(mTimeUseFly);

            currentCamera = targetCamera;
//          RemoteGather.currentCameraUniversal = currentCamera;
//          Debug.Log(2222);
            RemoteGather.lastSendCameraCameraState = currentCamera.GetCameraState();
        }
    }
    void OnEnable()
    {
        if (!Application.isPlaying)
        {
            c             = (CameraUniversal)target;
            cOriginActive = c.gameObject.activeInHierarchy;

            pos      = c.camBase.localPosition;
            xyzCount = new Vector3(c.Xcount, c.Ycount, c.Zcount);
        }
    }
Esempio n. 4
0
    void ChangeCameraWithName(string targetCameraName, float mTimeUseFly = 2)
    {
        CameraUniversal c = cameras.Find(s => s.camName == targetCameraName);

        if (c != null)
        {
            ChangeCamera(c, mTimeUseFly);
        }
        else
        {
            Debug.Log("找不到" + targetCameraName + "相机");
        }
    }
Esempio n. 5
0
    /// <summary>
    /// 切换相机方式二,位置移动及参数变化
    /// </summary>
    public void ChangeCamera2(CameraUniversal targetCamera, float mTimeUseFly = 2)
    {
        Debug.Log("ChangeCamera2");

        AddCameraToGroup(targetCamera);

        if (targetCamera != null && targetCamera != currentCamera)
        {
            lastCamera = currentCamera;

            if (currentCamera.playAnimationPath)
            {
                currentCamera.CameraPathStopPlay();
            }

            DOTween.Kill(currentCamera.transform);
            DOTween.Kill(targetCamera.transform);

            currentCamera.DisableCamera();
            targetCamera.EnableCamera();

            //判断是否是镜像户型,会进行镜像操作
            targetCamera.MoveToInitPosition(0);

            targetCamera.DisableCameraCtrl();
            targetCamera.changingCamera = true;

            Vector3    toPos = targetCamera.transform.localPosition;
            Quaternion toRo  = targetCamera.transform.localRotation;


            targetCamera.transform.position = lastCamera.transform.position;
            targetCamera.transform.rotation = lastCamera.transform.rotation;

            DOTween.Kill(targetCamera.transform);
            targetCamera.transform.DOLocalMove(toPos, mTimeUseFly);
            targetCamera.transform.DOLocalRotateQuaternion(toRo, mTimeUseFly).OnComplete(() => { targetCamera.changingCamera = false; targetCamera.EnableCameraCtrl(); targetCamera.transform.localRotation = new Quaternion(); });

            currentCamera = targetCamera;


            if (currentCamera.name == "CameraNK")
            {
                OnChangeToNKCamera.Invoke();
            }
            else if (currentCamera.name == "CameraMY")
            {
                OnChangeToMYCamera.Invoke();
            }
        }
    }
Esempio n. 6
0
    public void AddCameraToGroup(CameraUniversal addIn)
    {
        if (addIn == null)
        {
            GlobalDebug.Addline("AddCameraToGroup addIn 为空");
            Debug.LogError("AddCameraToGroup addIn 为空");
            return;
        }

        if (!cameras.Contains(addIn))
        {
            addIn.InitlCameraInRuntime();
            cameras.Add(addIn);
        }
    }
Esempio n. 7
0
    public void CloseVRGlass()
    {
        Input.gyro.enabled           = true;
        this.transform.parent        = globalManager;
        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
        moveUI.AlphaPlayBackward();
        zhunxUI.AlphaPlayBackward();

        leftEyeCamera.enabled  = false;
        rightEyeCamera.enabled = false;
        cameraUniversal.GetComponent <Camera>().enabled = true;
        cameraUniversal.ResetCameraStateToInitial();
//        cameraUniversal.vrMoveForward = false;
        cameraUniversal = null;
        defaultGUI.AlphaPlayForward();
    }
Esempio n. 8
0
 public static void SetupRemoteGather()
 {
     if (!hasInit)
     {
         allImageButton          = new Dictionary <string, ImageButton>();
         allScaleImage           = new Dictionary <string, ScaleImage>();
         needSendAckMessages     = new List <RemoteMessage>();
         needSendBtnCtrlMessages = new List <RemoteMessage>();
         needProcessMessages     = new List <RemoteMessage>();
         currentCtrlScaleImage   = null;
         currentCameraUniversal  = null;
         RemoteMessage.globalID  = 0;
         hasInit = true;
         Debug.Log("RemoteGatherInit");
         GlobalDebug.Addline("RemoteGatherInit");
     }
 }
Esempio n. 9
0
    public void OpenVRGlass()
    {
        defaultGUI.AlphaPlayBackward();
        CameraUniversal inCamera = globalManager.GetComponent <SceneInteractiveManger>().currentActiveSenceInteractiveInfo.cameraUniversalCenter.currentCamera;

        Input.gyro.enabled = true;

        cameraUniversal = inCamera;
        cameraUniversal.GetComponent <Camera>().enabled = false;
        leftEyeCamera.enabled  = true;
        rightEyeCamera.enabled = true;

        this.transform.parent        = inCamera.transform;
        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
        moveUI.AlphaPlayForward();
        zhunxUI.AlphaPlayForward();

        leftEyeCamera.cullingMask  = inCamera.GetComponent <Camera>().cullingMask;
        rightEyeCamera.cullingMask = inCamera.GetComponent <Camera>().cullingMask;
    }
Esempio n. 10
0
    public void RenderSenceThumbnail(SenceInteractiveInfo needRenderScene, CameraUniversal cameraThumbnail, string cameraArgs = "")
    {
        bool orginDisplayState = false;

        if (needRenderScene.sceneType == SenceInteractiveInfo.SceneType.大场景)
        {
            orginDisplayState = needRenderScene.meshRoot.gameObject.activeInHierarchy;
            needRenderScene.meshRoot.gameObject.SetActive(true);
        }
        else
        {
            if (needRenderScene.huXingType.hxMeshRoot != null)
            {
                orginDisplayState = needRenderScene.huXingType.hxMeshRoot.gameObject.activeInHierarchy;
                needRenderScene.huXingType.hxMeshRoot.gameObject.SetActive(true);
            }
        }

        cameraThumbnail.GetComponent <Camera>().targetTexture = thumbnail;
        cameraThumbnail.EnableCamera();
        if (cameraArgs != "")
        {
            cameraThumbnail.SetCameraPositionAndXYZCount(cameraArgs, 0);
        }
        cameraThumbnail.GetComponent <Camera>().Render();
        cameraThumbnail.DisableCamera();
        cameraThumbnail.GetComponent <Camera>().targetTexture = null;

        if (needRenderScene.sceneType == SenceInteractiveInfo.SceneType.大场景)
        {
            needRenderScene.meshRoot.gameObject.SetActive(orginDisplayState);
        }
        else
        {
            if (needRenderScene.huXingType.hxMeshRoot != null)
            {
                needRenderScene.huXingType.hxMeshRoot.gameObject.SetActive(orginDisplayState);
            }
        }
    }
Esempio n. 11
0
    public void OpenVRGlass()
    {
//     leftViewImage.rectTransform.anchoredPosition = new Vector2(-0.25f * Screen.width, 0);
//     leftViewImage.rectTransform.sizeDelta = new Vector2(-0.5f * Screen.width, 0);
//     rightViewImage.rectTransform.anchoredPosition = new Vector2(0.25f * Screen.width, 0);
//     rightViewImage.rectTransform.sizeDelta = new Vector2(-0.5f * Screen.width, 0);
//     rightViewImage

        defaultGUI.AlphaPlayBackward();
        CameraUniversal inCamera = globalManager.GetComponent <SceneInteractiveManger>().currentActiveSenceInteractiveInfo.cameraUniversalCenter.currentCamera;

        Input.gyro.enabled = true;

        cameraUniversal = inCamera;
//      cameraUniversal.GetComponent<Camera>().enabled = false;

        leftEyeCamera.enabled  = true;
        rightEyeCamera.enabled = true;

        this.transform.parent        = inCamera.transform;
        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
        moveUI.AlphaPlayForward();
        zhunxUI.AlphaPlayForward();

        leftEyeCamera.cullingMask  = inCamera.GetComponent <Camera>().cullingMask;
        rightEyeCamera.cullingMask = inCamera.GetComponent <Camera>().cullingMask;
        orginCameraClearFlags      = cameraUniversal.GetComponent <Camera> ().clearFlags;
        orginBackgroundColor       = cameraUniversal.GetComponent <Camera> ().backgroundColor;

        cameraUniversal.GetComponent <Camera>().cullingMask      = 0;
        cameraUniversal.GetComponent <Camera> ().clearFlags      = CameraClearFlags.SolidColor;
        cameraUniversal.GetComponent <Camera> ().backgroundColor = Color.white;


        vrViewCanveGroupFade.AlphaPlayForward();

        appBridge.Unity2App("unityVRState", "1");
    }
Esempio n. 12
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);
    }
Esempio n. 13
0
    public override void OnInspectorGUI()
    {
        //      Debug.Log("111111111");
        SerializedObject argsSerializedObject = new SerializedObject(target);

        if (Application.isPlaying)
        {
            c = (CameraUniversal)target;
        }

        SerializedProperty sp = argsSerializedObject.GetIterator();

        Undo.RecordObject(target, "LabelTextrueRender");
        EditorUtility.SetDirty(target);


        EditorGUILayout.Space();
        GUILayout.TextField("", GUILayout.MaxHeight(1));

        EditorGUILayout.BeginHorizontal();

        if (!Application.isPlaying)
        {
            if (GUILayout.Button("调整位置", GUILayout.MaxWidth(100), GUILayout.Height(30)))
            {
                inEditor = !inEditor;
                if (inEditor)
                {
                    c.gameObject.SetActive(true);
                }
                else
                {
                    c.gameObject.SetActive(cOriginActive);
                }
            }
        }

        if (GUILayout.Button("打印当前参数", GUILayout.MaxWidth(100), GUILayout.Height(30)))
        {
            if (c != null)
            {
                Debug.Log(preinfo + ":    " + c.GetCameraStateJson());
            }
        }
        preinfo = GUILayout.TextArea(preinfo, GUILayout.MaxWidth(60), GUILayout.Height(30));

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        GUILayout.TextField("", GUILayout.MaxHeight(1));

        if (inEditor)
        {
            pos      = c.camBase.localPosition;
            xyzCount = new Vector3(c.Xcount, c.Ycount, c.Zcount);

            GUI.backgroundColor = new Color(0, 1, 0);

            pos      = EditorGUILayout.Vector3Field("Position:", pos);
            xyzCount = EditorGUILayout.Vector3Field("xyzCount:", xyzCount);

            c.camBase.localPosition = pos;
            c.Xcount = xyzCount.x;
            c.Ycount = xyzCount.y;
            c.Zcount = xyzCount.z;

            GUI.backgroundColor = new Color(1, 1, 1);
        }



        //第一步必须加这个
        sp.NextVisible(true);

        while (sp.NextVisible(false))
        {
            EditorGUILayout.PropertyField(sp, true);
        }
        argsSerializedObject.ApplyModifiedProperties();

        if (inEditor)
        {
            c.InitlCameraInEditor();
        }
    }
Esempio n. 14
0
        public RemoteMessage(int inMessageType, string inCtrlBtnName = "", bool inBtnState = false, CameraUniversal c = null, ScaleImage s = null)
        {
            if (inCtrlBtnName.Length > 32)
            {
                string log = "按钮名字超过32个字符" + inCtrlBtnName;
                GlobalDebug.Addline(log);
                Debug.Log(log);
                Debug.LogWarning(log);
                Debug.LogError(log);
            }

            id = globalID;

            messageType = (byte)inMessageType;
            btnName     = inCtrlBtnName.PadLeft(32, '^');


            if (inBtnState)
            {
                btnState = 65;
            }
            else
            {
                btnState = 64;
            }


            if (c == null)
            {
                cameraStates = new float[] { 0, 0, 0, 0, 0, 0 };
            }
            else
            {
                cameraStates = c.GetCameraState();
            }

            if (s == null)
            {
                scaleImageStates = new float[] { 0, 0, 0 };
            }
            else
            {
                scaleImageStates = s.GetState();
            }


            GenBytes();

            globalID++;
        }