Issue iterating through images using LoadImage
Posted: Thu Dec 28, 2023 9:03 pm
Hello!
I am currently trying to save and load images using Easy Save 3's SaveImage/LoadImage. It seems to work as expected except when I'm trying to loop through GameObjects and load images using either a for loop or a coroutine. For some reason, all the GameObjects render the last image I was trying to load (screenshot attached). Not sure why that is. When I try to space them out using a coroutine/waitforseconds the images fail to render at all.
This is the code I'm using (condensed to the relevant parts)
Should I not be looping through and trying to load images? Is there some latency I need to account for? I have tried various solutions without success.
I am currently trying to save and load images using Easy Save 3's SaveImage/LoadImage. It seems to work as expected except when I'm trying to loop through GameObjects and load images using either a for loop or a coroutine. For some reason, all the GameObjects render the last image I was trying to load (screenshot attached). Not sure why that is. When I try to space them out using a coroutine/waitforseconds the images fail to render at all.
This is the code I'm using (condensed to the relevant parts)
Code: Select all
for (int i = 0; i < PhotosData.AllPhotos[i].Count; i++)
{
GameObject CurrentItemGameObject = PhotosGameObjects[i];
//This file path is unique to each photo, I double checked this already
string CurrentPhotoName = PhotosData.AllPhotos[i].PhotoFilePath;
Texture2D Texture = ES3.LoadImage(CurrentPhotoName);
Texture.filterMode = FilterMode.Point;
Texture.wrapMode = TextureWrapMode.Clamp;
CurrentItemGameObject.transform.Find("PhotoImage").GetComponent<Image>().material.mainTexture = Texture;
CurrentItemGameObject.transform.Find("PhotoImage").gameObject.SetActive(true);
}