My project involves snapping pictures of peoples faces from a webcam and attaching them as particles of separate particle systems. I have successfully attached the live webcam to the particle system but I am unsure how to make still frames from the live feed. Should I create a folder outside of Unity that I can store the images, and then call on them for the particle system in Unity? If that makes sense how would I do that with JavaScript?
`
var captureTexture : WebCamTexture;
function Start (){
webcamTexture = new WebCamTexture();
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
function Update () {
if(Input.GetMouseButtonDown(0)){
webCamSnapper[1] == WebCamTexture;
Debug.Log("does it work?");
}
}`
I’ll be happy to provide any more details, thank you for your help!
You don’t need to go to the trouble of saving to disk unless you’re going to run out of memory, or want the images to be available between runs of your application. You can get the color information of the current frame of webcam data with Unity - Scripting API: WebCamTexture.GetPixels - you can then use Unity - Scripting API: Texture2D.SetPixels to write it into a regular old Texture2D, which you can then save in memory and use as you wish.