Esempio n. 1
0
        private void UpdateCamera(int id, MockCamera mockCam)
        {
            if (NativeApi.HasCameraWithId(id))
            {
                cameraProperties.position.x = mockCam.position.x;
                cameraProperties.position.y = mockCam.position.y;
                cameraProperties.position.z = mockCam.position.z;

                cameraProperties.rotation.x = mockCam.rotation.x;
                cameraProperties.rotation.y = mockCam.rotation.y;
                cameraProperties.rotation.z = mockCam.rotation.z;
                cameraProperties.rotation.w = mockCam.rotation.w;

                cameraProperties.fov              = mockCam.fov;
                cameraProperties.near             = mockCam.near;
                cameraProperties.far              = mockCam.far;
                cameraProperties.textureWidth     = mockCam.textureWidth;
                cameraProperties.textureHeight    = mockCam.textureHeight;
                cameraProperties.renderingMode    = (int)mockCam.stereoRenderingMode;
                cameraProperties.eyeSeparation    = mockCam.eyeSeparation;
                cameraProperties.leftAbberation.x = mockCam.leftAbberation.x;
                cameraProperties.leftAbberation.y = mockCam.leftAbberation.y;
                cameraProperties.leftAbberation.z = 0;

                cameraProperties.rightAbberation.x = mockCam.rightAbberation.x;
                cameraProperties.rightAbberation.y = mockCam.rightAbberation.y;
                cameraProperties.rightAbberation.z = 0;

                cameraProperties.enableLeftOcclusion  = mockCam.enableLeftOcclusion ? 1 : 0;
                cameraProperties.enableRightOcclusion = mockCam.enableRightOcclusion ? 1 : 0;

                NativeApi.UpdateCameraWithId(id, cameraProperties);
            }
        }
Esempio n. 2
0
        void OnGUI()
        {
            var displaySubsystem = GetXRDisplaySubsystem();

            EditorGUILayout.BeginVertical();

            EditorGUILayout.Space();
            if (GUILayout.Button("Add Camera"))
            {
                var newCam = new MockCamera();
                newCam.id = -1;
                additionalMockCameras.extraCameras.Add(newCam);
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            EditorGUILayout.Space();

            int camIndex = 0;

            camerasScrollPos = EditorGUILayout.BeginScrollView(camerasScrollPos, GUILayout.Width(EditorGUIUtility.currentViewWidth));
            foreach (var mockCam in additionalMockCameras.extraCameras)
            {
                EditorGUILayout.LabelField($"Mock Camera {camIndex}", EditorStyles.largeLabel);
                EditorGUILayout.Space();

                camIndex++;

                mockCam.position             = EditorGUILayout.Vector3Field("Position", mockCam.position);
                mockCam.rotation.eulerAngles = EditorGUILayout.Vector3Field("Rotation", mockCam.rotation.eulerAngles);
                mockCam.fov           = EditorGUILayout.FloatField("Field of View", mockCam.fov);
                mockCam.near          = EditorGUILayout.FloatField("Near", mockCam.near);
                mockCam.far           = EditorGUILayout.FloatField("Far", mockCam.far);
                mockCam.textureWidth  = EditorGUILayout.IntField("Texture Width", mockCam.textureWidth);
                mockCam.textureHeight = EditorGUILayout.IntField("Texture Height", mockCam.textureHeight);

                mockCam.stereoRenderingMode = (MockRenderingMode)EditorGUILayout.EnumPopup("Rendering Mode", mockCam.stereoRenderingMode);
                if (mockCam.stereoRenderingMode != MockRenderingMode.None)
                {
                    mockCam.eyeSeparation = EditorGUILayout.FloatField("Eye Separation", mockCam.eyeSeparation);
                    mockCam.eyeSeparation = Math.Max(Math.Min(5.0f, mockCam.eyeSeparation), 0.01f);
                }

                mockCam.enableLeftOcclusion = EditorGUILayout.Toggle("Left Occlusion: ", mockCam.enableLeftOcclusion);
                mockCam.leftAbberation      = EditorGUILayout.Vector2Field("Left Abberation: ", mockCam.leftAbberation);

                EditorGUILayout.Space();
                mockCam.enableRightOcclusion = EditorGUILayout.Toggle("Right Occlusion: ", mockCam.enableRightOcclusion);
                mockCam.rightAbberation      = EditorGUILayout.Vector2Field("Right Abberation: ", mockCam.rightAbberation);

                bool preIsActive = mockCam.isActive;
                mockCam.isActive = EditorApplication.isPlayingOrWillChangePlaymode ? EditorGUILayout.Toggle("Active", mockCam.isActive) : false;

                if (GUILayout.Button("Remove Camera"))
                {
                    camerasToRemove.Add(mockCam);
                    mockCam.isActive = false;
                }

                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            }
            EditorGUILayout.EndScrollView();


            EditorGUILayout.EndVertical();


            UpdateAllCameras();

            foreach (var mockCam in camerasToRemove)
            {
                additionalMockCameras.extraCameras.Remove(mockCam);
            }
        }