I am implementing one of the game feature that will load/change the picture of a certain GUITexture based on the data supplied from the previous screen.
so the data is in integer (0,1,2,…)
characterId[0]=1; characterId[1]=2; characterId[2]=3; characterId[3]=4;
and I have an array of Texture2D
pictureArray : Texture2D[]
whose values are already predefined from drag and dropping an image file through inspector
So later I can change the GUITexture’s texture of the picture like this
charaPic[0].texture = pictureArray[characterId[0]];
This works fine on unity player (mac), but when I tried to deploy it on iPad, there’s problem that the pictureArray
has length 0 when I try to print out the length on Start()
So I’m thinking, there may be lags when the script trying to initialize predefined values set from inspector. I tried to make a waiting mechanism until this array is fully initialized. Yield WaitForSeconds()
doesn’t seem to work that well in this case.
Is there any good workaround that I still can keep storing the picture in array?
Any inputs are greatly appreciated,
Update : Apparently, even if I don’t put the image into Array of Texture2D (just put it in single variable Texture2D), there’s problem fetching the data when running it on iPad