Skip to content

Instantly share code, notes, and snippets.

@olokobayusuf

olokobayusuf/StartingOff.cs Secret

Last active Sep 11, 2019
Embed
What would you like to do?
A minimal example showing how to get started with NatCam.
using UnityEngine;
using UnityEngine.UI;
using NatCam;
public class StartingOff : MonoBehaviour {
public RawImage rawImage;
public AspectRatioFitter aspectFitter;
private CameraDevice cameraDevice;
void Start () {
// Start the rear camera preview
cameraDevice = CameraDevice.GetDevices()[0];
cameraDevice.StartPreview(OnStart);
}
void OnStart (Texture preview) {
// Display the camera preview on our RawImage
rawImage.texture = preview;
// Set the aspect ratio of our UI panel to match that of the camera preview
aspectFitter.aspectRatio = preview.width / (float)preview.height;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.