Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Meltdown on June 17, 2015, 07:33:54 PM

Title: Unity 5.1, WebCamTexture not working with UITexture on Android
Post by: Meltdown on June 17, 2015, 07:33:54 PM
I'm using a WebCamTexture which updates the UITexture with whatever is seen by the device camera.

If I use a standard Unity plane and renderer as my texture, the texture is updated and shows what the camera is viewing, in both the editor and on my Android device.

However, if I use a UITexture, although the camera works in the editor and shows on the UITexture, it doesn't work on my Android device, there is just a black texture.

This is my script...
I am using NGUI 3.9.0

  1. public class WebcamTest : MonoBehaviour {
  2.         public string deviceName;
  3.         WebCamTexture wct;
  4.  
  5.         [SerializeField] UITexture _uiTexture;
  6.  
  7.         // Use this for initialization
  8.         void Start () {
  9.                 WebCamDevice[] devices = WebCamTexture.devices;
  10.                 deviceName = devices[0].name;
  11.                 wct = new WebCamTexture(deviceName, 400, 300, 12);
  12.                 //GetComponent<Renderer>().material.mainTexture = wct;
  13.                 //_uiTexture.material.mainTexture = wct;
  14.                 _uiTexture.mainTexture = wct;
  15.                 wct.Play();
  16.         }
  17. }
  18.  
Title: Re: Unity 5.1, WebCamTexture not working with UITexture on Android
Post by: ArenMook on June 18, 2015, 07:53:32 AM
Black texture means the texture format / size is not supported on your device. Many mobile devices need power-of-two texture sizes while yours isn't (400x300). Not sure why the plain texture works while UITexture doesn't in your case.