Search Unity

WebCam

Discussion in 'Scripting' started by kdarius43, Aug 1, 2015.

  1. kdarius43

    kdarius43

    Joined:
    Mar 16, 2015
    Posts:
    170
    Hello,

    I have cube X that has a script
    Code (CSharp):
    1. public class CameraPreview : MonoBehaviour {
    2.     WebCamTexture FrontPreviewCam;
    3.     string Frontcamera;
    4.  
    5.     // Use this for initialization
    6.     void Start () {
    7.    
    8.         WebCamDevice[] devices = WebCamTexture.devices;  
    9.         Frontcamera = devices[1].name;
    10.    
    11.         FrontPreviewCam = new WebCamTexture(Frontcamera,1920,1080,30);
    12.    
    13.         GetComponent<Renderer>().material.mainTexture = FrontPreviewCam;
    14.         FrontPreviewCam.Play ();
    15.     }
    now i have a button B that when pushed I want it to pause the webcamtexture that is in cube X
    how would i reference this in the button B Onmousedown script?

    thank you
     
  2. kdarius43

    kdarius43

    Joined:
    Mar 16, 2015
    Posts:
    170
    so i assume i need to make something like the fallowing.
    Code (CSharp):
    1.     void CamPause(){
    2.         FrontPreviewCam.Pause ();
    3.     }
    but not sure how to access that through the script that is on my button
     
  3. kdarius43

    kdarius43

    Joined:
    Mar 16, 2015
    Posts:
    170
    anyone have any thoughts?
     
  4. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    You could make a screenshot and display it while you pause