Search Unity

Vuforia - Saving background texture

Discussion in 'iOS and tvOS' started by Fabien-LG, Mar 27, 2014.

  1. Fabien-LG

    Fabien-LG

    Joined:
    Mar 9, 2013
    Posts:
    15
    Hello,

    I already asked the answer on Vuforia's forum, without answer, so I'm trying here as it's maybe more Unity-related.
    I'm trying to extend the "Background Texture" sample to be able to send the pixels data of the video texture to a Plugin.

    I can get the data in the Editor, but when I test on iOS, the texture is empty.

    Here is what I did :
    1. Setting mTexture to public in VideoTextureBehaviour.cs
    2. In another script, on a press on a GUI Button (far after the texture is properly initialized), I'm creating my own texture and set its pixels :

    // Texture creation :
    Texture2D myTexture = new Texture2D(
    _VideoTextureBehaviour.mTexture.width,
    _VideoTextureBehaviour.mTexture.height,
    TextureFormat.RGB24,
    false
    );

    // Prints 1 on iOS
    Debug.Log ("Video Texture length : " + _VideoTextureBehaviour.mTexture.GetPixels32().Length );

    // Sets texture bytes :
    myTexture.SetPixels32( _VideoTextureBehaviour.mTexture.GetPixels32() );
    myTexture.Apply();

    // Saves empty texture on iOS, but correct in Editor:
    byte[] TexAsBytes = myTexture.EncodeToPNG();
    File.WriteAllBytes(Application.persistentDataPath + "/myTexture.png", TexAsBytes);


    Is there something I'm missing there on iOS ?

    Thanks !
     
  2. emorling

    emorling

    Joined:
    Jul 6, 2015
    Posts:
    24
    Were you able to solve this? I am gettings same problem on IOS. Its empty