private void TakePictureCallback(string path) { if (path != null) { // Create a Texture2D from the captured image in the cache Texture2D texture = NativeCamera.LoadImageAtPath(path, 1024); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; } // create sprite from the texture Sprite newSprite = Sprite.Create(texture, new Rect(Vector2.zero, new Vector2(texture.width, texture.height)), new Vector2(.5f, .5f)); if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)) { Permission.RequestUserPermission(Permission.ExternalStorageWrite); } if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite)) { NotificationManager.Instance.ShowNotification("External Write Permission Required"); return; } PathOfCurrentImage = NativeToolkit.SaveImage(texture, "Recipes"); print($"CameraManager: Path of Image {PathOfCurrentImage}"); OnPictureTaken?.Invoke(newSprite); } }
IEnumerator CaptureScreen() { yield return(new WaitForEndOfFrame()); Texture2D picture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, mipChain: false); Rect source = new Rect(0f, 0f, Screen.width, Screen.height); bool previousFullScreenState = Screen.fullScreen; Screen.fullScreen = true; picture.ReadPixels(source, 0, 0); picture.Apply(); Screen.fullScreen = previousFullScreenState; OnPictureTaken?.Invoke(picture); }