コード例 #1
0
        /// <summary>
        /// Start camera preview
        /// </summary>
        public ResultCode Start()
        {
#if PLATFORM_ANDROID
#if UNITY_2018_3_OR_NEWER
            if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
            {
                Permission.RequestUserPermission(Permission.Camera);
            }
#endif
#endif
            int cameraType = 0;
            if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
            {
                cameraType = AbstractConfigurationScriptableObject.GetInstance().WebcamType;
            }
            else
            {
                cameraType = (int)AbstractConfigurationScriptableObject.GetInstance().CameraType;
            }

            CameraDevice.CameraResolution cameraResolution = AbstractConfigurationScriptableObject.GetInstance().CameraResolution;
            switch (cameraResolution)
            {
            case CameraDevice.CameraResolution.Resolution640x480:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;

            case CameraDevice.CameraResolution.Resolution1280x720:
                preferredWidth  = 1280;
                preferredHeight = 720;
                break;

            case CameraDevice.CameraResolution.Resolution1920x1080:
                preferredWidth  = 1920;
                preferredHeight = 1080;
                break;

            default:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;
            }

            Debug.Log("Camera id : " + cameraId);

            return((ResultCode)NativeAPI.maxst_CameraDevice_start(cameraType, preferredWidth, preferredHeight));
        }
コード例 #2
0
        /// <summary>
        /// Start camera preview
        /// </summary>
        public ResultCode Start()
        {
            int cameraType = 0;

            if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
            {
                cameraType = AbstractConfigurationScriptableObject.GetInstance().WebcamType;
            }
            else
            {
                cameraType = (int)AbstractConfigurationScriptableObject.GetInstance().CameraType;
            }

            CameraDevice.CameraResolution cameraResolution = AbstractConfigurationScriptableObject.GetInstance().CameraResolution;
            switch (cameraResolution)
            {
            case CameraDevice.CameraResolution.Resolution640x480:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;

            case CameraDevice.CameraResolution.Resolution1280x720:
                preferredWidth  = 1280;
                preferredHeight = 720;
                break;

            case CameraDevice.CameraResolution.Resolution1920x1080:
                preferredWidth  = 1920;
                preferredHeight = 1080;
                break;

            default:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;
            }

            Debug.Log("Camera id : " + cameraId);

            return((ResultCode)NativeAPI.CameraDevice_start(cameraType, preferredWidth, preferredHeight));
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab)
            {
                return;
            }

            configuration = (ConfigurationScriptableObject)target;

            isDirty = false;

            licenseFold = EditorGUILayout.Foldout(licenseFold, "License Key Setting");
            if (licenseFold)
            {
                EditorGUILayout.LabelField("License key");
                string licenseKey = configuration.LicenseKey;
                configuration.LicenseKey = EditorGUILayout.TextArea(licenseKey, GUILayout.MaxHeight(40));
                EditorGUILayout.HelpBox("Please register your app at https://developer.maxst.com/.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(licenseKey, configuration.LicenseKey) == false)
                {
                    isDirty = true;
                }
            }

            cameraFold = EditorGUILayout.Foldout(cameraFold, "Camera Settings");
            if (cameraFold)
            {
                CameraDevice.CameraType cameraType = configuration.CameraType;
                configuration.CameraType = (CameraDevice.CameraType)EditorGUILayout.EnumPopup("Mobile Camera Type", cameraType);
                EditorGUILayout.HelpBox("Camera settings in mobile app", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(cameraType, configuration.CameraType) == false)
                {
                    isDirty = true;
                }

                int webcamType = configuration.WebcamType;
                configuration.WebcamType = EditorGUILayout.Popup("Webcam Type", webcamType, LoadWebcamDeviceList());
                EditorGUILayout.HelpBox("Webcam settings in Editor mode.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(webcamType, configuration.WebcamType) == false)
                {
                    isDirty = true;
                }

                CameraDevice.CameraResolution cameraResolution = configuration.CameraResolution;
                configuration.CameraResolution = (CameraDevice.CameraResolution)EditorGUILayout.EnumPopup("Camera Resolution", cameraResolution);
                EditorGUILayout.HelpBox("Please select a supported resolution.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(cameraResolution, configuration.CameraResolution) == false)
                {
                    isDirty = true;
                }

                WearableCalibration.WearableType wearableType = configuration.WearableType;
                configuration.WearableType = (WearableCalibration.WearableType)EditorGUILayout.EnumPopup("Wearable Type", wearableType);
                EditorGUILayout.HelpBox("Please select a wearable type.", MessageType.Info);
                EditorGUILayout.Space();
                if (string.Equals(wearableType, configuration.WearableType) == false)
                {
                    isDirty = true;
                }
            }

            if (GUI.changed && isDirty)
            {
                EditorUtility.SetDirty(configuration);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }