Saving Webcam textures to separate particle system textures.

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!

Joe

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.

Hey thank you for your reply!

Could I trouble you for some coded examples? I looked at the provided links and saw:

GetPixels (x : int, y : int, blockWidth : int, blockHeight : int) : Color

Is this declared globally? What would fill the arguments? Example:

webcamTexture.GetPixels(0,0,?,?);

Are the X and the Y the location of where the block begins? And the 3rd and 4th parameter for how big the block is?

Once I have the pixel data how would I form a new texture with SetPixels?

Your help is very much appreciated!