- Home /
Question by
Rinku249 · Mar 15, 2021 at 11:48 AM ·
2dui image2d spritesbytearray
LoadImage not loading full image,LoadImage not working properly
Hello, I'm Currently writing a software that download images from the internet and saves them to disk for future use (I can give the code if its needed). Thing is, in memory these files look good, I open them with another software and they look complete; However using unity's LoadImage function, the image is loaded partially (img attached) it happens to every image that is loaded.
I would appreciate some help as i've been in this problem from quite some while.
public IEnumerator Reloading(){
Texture2D texture = new Texture2D(2, 2);
for (int i = 0; i<q.Count;i++){
QuestionImages.Add(new List<Sprite>());
for(int j=0; j<q[i].photoURL.Count;j++){
print("jr");
QuestionImages[i].Add(Sprite.Create(new Texture2D(2,2), new Rect(0,0, 2, 2), Vector2.one/2));
UnityEngine.ImageConversion.LoadImage(texture, loadimage(i,j));
yield return new WaitForSeconds(1f);
hello.sprite = Sprite.Create(texture, new Rect(0,0, texture.width, texture.height), Vector2.one/2);
QuestionImages[i][j] = Sprite.Create(texture, new Rect(0,0, texture.width, texture.height), Vector2.one/2);
}
}
}
public byte[] loadimage(int x, int y)
{
byte[] bar = File.ReadAllBytes(Application.dataPath + "/photos/img" + x + "_" + y + ".png");
return bar;
}
15ee2325fb3ea68614e16291fd61ed6f.png
(9.2 kB)
img0-7.png
(92.6 kB)
Comment
Your answer
Follow this Question
Related Questions
Update Polygon Collider 2d on skeletal animations 0 Answers
Run a shader once on a texture 1 Answer
moving player top down,movement in unity 2d 0 Answers
Rendering layer mask not working 0 Answers