i am working on this game and the image is displayed fine in the game screen in Unity editor but when i build and run the image is blank. Game view in unity: !(Game view in unity) the view after building the texture source is the hard drive. the image is not in the project folder and is not built Any suggestions? Please note i am learning unity and CSharp(New user).
Button Code:
public Category category;
public TextMeshProUGUI text;
public RawImage image;
public bool isFilled = false;
public int directoryLineNumber;
public void UpdateButtonData()
{
text.text = category.name;
image.texture = category.GetARandomImage();
//image.Rebuild(0);
isFilled = true;
}
{
public string name;
public string text;
public List<Item> items;
private string _path;
//some code here not related
public Texture2D GetARandomImage()
{
DirectoryInfo dir = new DirectoryInfo(_path);
FileSystemInfo[] images = dir.GetFileSystemInfos();
int i = Random.Range(0, images.Length);
if (images[i].ToString().Contains(".png"))
{
WWW wWW = new WWW(images[i].ToString());
/* Wait !! */
while (!wWW.isDone) { }
return wWW.texture;
}
else return GetARandomImage();
}