banner



How To Switch Between Front And Back Camera In Android Unity Using Webcam Texture

Tape video and Capture photos in app — Unity Android

  1. Capture Photos
  2. Tape Videos
  1. Native Gallery for Android & iOS | Integration | Unity Asset Shop
  2. NatCorder — Video Recording API | Integration | Unity Asset Shop

Capture Photos

          using NatSuite.Recorders;          using NatSuite.Recorders.Clocks;        
          public RawImage rawimage;          private WebCamTexture webcamTexture;        
          void Start()          {
//Obtain camera devices available
WebCamDevice[] cam_devices = WebCamTexture.devices; //Ready a camera to the webcamTexture webcamTexture = new WebCamTexture(cam_devices[0].proper name, 480, 640, 30); //Set the webcamTexture to the texture of the rawimage rawimage.texture = webcamTexture; rawimage.material.mainTexture = webcamTexture; //Start the camera
webcamTexture.Play();
}
          individual IEnumerator SaveImage()          {          //Create a Texture2D with the size of the rendered image on the screen.          Texture2D texture = new Texture2D(rawimage.texture.width, rawimage.texture.height, TextureFormat.ARGB32, false);          //Save the epitome to the Texture2D          texture.SetPixels(webcamTexture.GetPixels());          //texture = RotateTexture(texture, -90);          texture.Use();          yield return new WaitForEndOfFrame();          // Save the screenshot to Gallery/Photos          NativeGallery.Permission permission = NativeGallery.SaveImageToGallery(texture, "CameraTest", "CaptureImage.png", (success, path) => Debug.Log("Media save result: " + success + " " + path));          // To avoid memory leaks          Destroy(texture);          }        
          public void clickCapture()          {          StartCoroutine(SaveImage());          }        

Source: https://nirmalmendis.medium.com/record-video-and-capture-photos-in-app-unity-android-d2e6729284cd

Posted by: kilbyindart.blogspot.com

0 Response to "How To Switch Between Front And Back Camera In Android Unity Using Webcam Texture"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel