Hi
I ran into an issue with Texture2D.Apply(). I fixed my problem but i’m not sure about the reason though.
Quick explanation : I made an android messaging app, and i’m basically sending raw picture via string message.(whatever)
//create contact
Contact newContact = new Contact(result.IdSender,result.Contact.Pseudo);
Texture2D tex = new Texture2D(result.Contact.Picture.Width,result.Contact.Picture.Height, TextureFormat.RGBA32, false);
tex.LoadRawTextureData(result.Contact.Picture.Raw);
tex.Apply();
newContact.picture = tex;
//At this point, sometimes my texture2D appears all black. But if i read some pixels color, there are not black (they have the expected color).
contacts.Add(result.IdSender, newContact);
Sometimes, the Texture2D i stored in this piece of code will show a totally black image everywhere i will use it. I first believed that my pixels values where incorect for some reason, but i checked and the pixels values are correct. I found out that i need to call Texture2D.Apply() again to fix the problem on the faulty texture.
I’m not sure to understand why.
My theory is that Texture2D.Apply() is somehow slow and sometimes it’s not finnished before the next line of code (where i assign this texture). But if it’s the case then Texture2D.Apply() would be a kind of asynchronous task ? Then is there a callback function or something that i can use to make sure the texture has been well applyed ?
I’m not sure if my assumption make sense but in any case i would like to have a way to know if i need to call Texture2D.Apply() again or not
Thanks,
Thibault