Giving time until an object is fully initialized

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,…)


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

There aren’t any lags. Scripting would be pretty much impossible if you couldn’t count on everything being executed in a strictly linear, synchronous order (except where explicitly documented as being asynchronous), so putting WaitForSeconds in won’t accomplish anything. The array is either initialized or it’s not…there’s no state where it’s in the process of being initialized, so by the time Start runs, it’s initialized.

As to what the actual problem is, maybe you’re using a type of texture compression that’s not available on iOS?

Are you textures power of 2 and square? iOS devices used to require this, not sure about the iPad, iPhone 4 or iPad 2.

When I was working natively on the iPhone (very slow without an engine I can tell you!), the phone would just silently fail to load a texture - maybe you’re getting the same? However if targeting for iOS I would have thought Unity would be setting the texture to compressed and enforcing power of 2 etc by default…

I recommend trying this with one picture (as you have) but that is a plain vanilla 16x16 texture to see if it works.