Search Unity

WebCamTexture cannot be displayed in Windows 8 tablet(HP ElitePad)

Discussion in 'Windows' started by CipherZero, Sep 25, 2013.

  1. CipherZero

    CipherZero

    Joined:
    Jul 10, 2013
    Posts:
    38
    UPDATE:
    I've found out that the plane didn't actually disappeared, it's just it has used some garbage texture which has the same color of that of skybox(or maybe it's transparent)

    Now I've used WebCamDevice to somehow make the plane to display the first "webcam's texture", though it's all black in color, which probably is a result of haven't turn on the webcam.

    Clarifying:
    I'm trying to build an exe file to run on the target tablet(HP elitepad), but as I've mentioned above, the camera can't be turned on. That makes me to think that maybe I need to somehow build the project as Windows Store App to make the camera to be working

    Hello everyone, currently I'm working on a project that involves using built-in camera to display what the camera sees. The scene in my project is a very simple setup, a Main Camera, a plane object for displaying what the built-in camera sees and a directional light. The below code is attached to the plane and works perfectly in editor.
    Code (csharp):
    1. private WebCamTexture webTEX;
    2. void Start ()
    3. {
    4.     webTEX = new WebCamTexture();
    5.     renderer.material.mainTexture = webTEX;
    6.     webTEX.Play();
    7. }
    But when I built and project and put it into the tablet for testing, the plane just simply disappeared.

    I've tried another approach:
    Code (csharp):
    1. IEnumerator Start()
    2. {
    3.         yield return Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone);
    4.         if (Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone))
    5.     {
    6.         webTEX = new WebCamTexture();
    7.         renderer.material.mainTexture = webTEX;
    8.         webTEX.Play();
    9.         } else {
    10.            
    11.         }
    12. }
    But still no luck.

    so I've used OnGUI() to display some information for debugging:
    Code (csharp):
    1. void OnGUI()
    2. {
    3.     GUI.Box(new Rect(10, 10, 100, 100), "hello world");
    4.    
    5.     GUI.Box(new Rect(10, 120, 250, 100), webTEX.deviceName);
    6. }
    And they work perfectly fine in the editor and in the tablet. Both giving out the text "hello world" and the cameras' name.

    Anyone have any idea that I can make this work? Any help would be greatly appreciated.
    (My unity version is Version 3.5.7f6)
     
    Last edited: Sep 26, 2013
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    WebCamTexture support has only recently been added (4.3, don't know which alpha/beta).
     
  3. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    Your thread topic suggests that you're talking about Windows Store Apps, but it feels like you're talking about Windows Standalone player, so which one is it?
     
  4. CipherZero

    CipherZero

    Joined:
    Jul 10, 2013
    Posts:
    38
    sorry for the confusion ( and i need to update a bit of the testing result of my trial and error)
    UPDATE:
    I've found out that the plane didn't actually disappeared, it's just it has used some garbage texture which has the same color of that of skybox(or maybe it's transparent)

    Now I've used WebCamDevice to somehow make the plane to display the first "webcam's texture", though it's all black in color, which probably is a result of haven't turn on the webcam.

    for the clarifying part:
    I'm trying to build an exe file to run on the target tablet(HP elitepad), but as I've mentioned above, the camera can't be turned on. That makes me to think that maybe I need to somehow build the project as Windows Store App to make the camera to be working

    (I'm sorry for my broken English, I hope you guys can all get what I'm trying to say)
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    I see, well if you'll have troubles with WebCam on Windows Store Apps, please poke again.
     
  6. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    Set your VS 2012 debugger to debug C++ instead of C# and you may get back some errors. WebCam stuff is done in C++.