I'm creating an array of Texture so I'm doing it like this
[SerializeField] GameObject[] uitex = new GameObject[4];
void GetTextureFromServer()
{
string dealer_image = "";
var tex = new Texture2D(20, 20);
for (int i = 0; i < tzPlayInfo.Instance.bc_gametablelist.Count; i++)
{
dealer_image += tzPlayInfo.Instance.bc_gametablelist[i].dlrimage;
dealer_image += ",";
}
string[] NewLinks = dealer_image.Split(',');
for(int j = 0; j < NewLinks.Length - 1; j++)
{
Debug.Log("HERE ARE THE LINKS : " + NewLinks[j]);
new BestHTTP.HTTPRequest(new System.Uri("***********.amazonaws.com/resources" + "/dealer/pic/" + NewLinks[j]),
(BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res) =>
{
tex.LoadImage(res.Data);
}).Send();
}
for (int i = 0; i < uitex.Length; i++)
{
uitex[i].GetComponent<UITexture>().mainTexture = tex;
}
}
What i tried so far is this
uitex[j].GetComponent<UITexture>().mainTexture = tex;
But it gives me an array is out of range and i don't know why.
The problem with this code is that it always gets the last index i have so all 4 gameobject has the same all textures and that's not what i want. Could someone please help me with my problem . Thank you.