/// <summary> /// Set device orientation and surface size /// </summary> void InitInternal() { licenseKey = AbstractConfigurationScriptableObject.GetInstance().LicenseKey; #if UNITY_IOS && !UNITY_EDITOR NativeAPI.init(licenseKey); #endif // If CameraBackgroundBehaviour is not activated when start application, projection matrix // can not be made because screen width and height isn't set properly. if (screenWidth != Screen.width || screenHeight != Screen.height) { screenWidth = Screen.width; screenHeight = Screen.height; MaxstAR.OnSurfaceChanged(screenWidth, screenHeight); } if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { MaxstAR.SetScreenOrientation((int)Screen.orientation); } else { MaxstAR.SetScreenOrientation((int)ScreenOrientation.LandscapeLeft); } arCamera = GetComponent <Camera>(); }
/// <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)); }
/// <summary> /// Get configuration asset instance /// </summary> /// <returns>Configuration scriptable object</returns> public static AbstractConfigurationScriptableObject GetInstance() { if (configuration == null) { configuration = Resources.Load <AbstractConfigurationScriptableObject>("MaxstAR/Configuration"); // To Create Asset //configuration = CreateInstance<ConfigurationScriptableObject>(); //AssetDatabase.CreateAsset(configuration, "Assets/Resources/Configuration.asset"); //AssetDatabase.Refresh(); } if (configuration == null) { Debug.LogError("Configuration is null"); } return(configuration); }
/// <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)); }