Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

LoadRawTextureData: not enough data provided

Discussion in 'Windows' started by killer_bigpoint, Nov 5, 2016.

  1. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
    Hello, so i'm sending my sprite over the network by getting the texture from it, then converting it into a byte array

    Then im sending the byte AND the size of the texture, but when i use LoadRawTextureData, it says the texture size is too big?, please help

    This is the code that sends it
    Code (JavaScript):
    1. PhotonView.RPC("SetUserInfo", PhotonTargets.AllBufferedViaServer, textureBytes,  new Vector2(texture.width, texture.height));
    and this is the code that assembles it again on the other end, but its also here where the error gets thrown
    Code (JavaScript):
    1. var objTexture : Texture2D = new Texture2D(textureSize.x, textureSize.y);
    2.         objTexture.LoadRawTextureData(textureBytes);
    3.         objTexture.Apply();
     
  2. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
    Just to be clear, this is how i'm getting the texture from the sprite
    Code (JavaScript):
    1. var textureBytes : byte[] = spriteIcon.texture.GetRawTextureData();
     
  3. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    ina likes this.
  5. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
    I even tried this with no luck, still the same

    Code (JavaScript):
    1. icon = GameJolt.API.Manager.Instance.CurrentUser.Avatar;
    2.  
    3. var textureTemp : Texture2D = icon.texture;
    4.  
    5.                 var textureOriginal : byte[] = textureTemp.GetRawTextureData();
    6.                 var textureCompressed : byte[] = CLZF2.Compress(textureOriginal);
    7.  
    8.                 Debug.Log("original: " + textureOriginal.length + " | compressed: " + textureCompressed.length + " | size: " + new Vector2(textureTemp.width, textureTemp.height));
    9.  
    10.                 var textureDecompressed : byte[] = CLZF2.Decompress(textureCompressed);
    11.  
    12.                 Debug.Log("original2: " + textureDecompressed.length + " | compressed2: " + textureCompressed.length);
    13.  
    14.                 var objTexture : Texture2D = new Texture2D(textureTemp.width, textureTemp.height);
    15.                 objTexture.LoadRawTextureData(textureOriginal);
    16.                 objTexture.Apply();
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    Please see the attached project. works well for me.
     

    Attached Files:

    Psyco92 likes this.
  7. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
    just to be sure, does the code i've made work with jpeg? because its only when i use jpeg it doens't work
     
  8. killer_bigpoint

    killer_bigpoint

    Joined:
    Jul 11, 2015
    Posts:
    19
    Nevermind, i got it working now!

    The only thing i need to add was this little bit of code -.-'
    Code (JavaScript):
    1. TextureFormat.RGBA32, false