Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Video camera feed only gives still frame on mobile

Discussion in 'Audio & Video' started by enhawk, Nov 29, 2017.

  1. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    835
    Using Unity 2017.2, iOS 11.1

    I can get the video and put it in a texture, but it seems to freeze on the first frame

    it works fine on a pc

    Heres the code, any ideas?

    Code (csharp):
    1.  
    2. public class CameraTexture : MonoBehaviour {
    3.  
    4.     WebCamTexture camtex;
    5.     Renderer r;
    6.     void Start() {
    7.  
    8.         WebCamDevice[] devices = WebCamTexture.devices;
    9.         for (int i = 0; i < devices.Length; i++)
    10.         {
    11.             if (devices[i].isFrontFacing)
    12.             {
    13.                 camtex = new WebCamTexture(devices[i].name);
    14.             }
    15.         }
    16.         camtex.Play();
    17.         r = GetComponent<Renderer>();
    18.         r.material.mainTexture = camtex;
    19.     }
    20.     void Update()
    21.     {
    22.         if (!camtex.isPlaying)
    23.         {
    24.             camtex.Play();
    25.         }
    26.         if (camtex.didUpdateThisFrame)
    27.         {
    28.             r.material.mainTexture = camtex;
    29.         }
    30.     }
    31. }
    32.