Hi, I'm missing something very obvious from this script as it loads the texture in to all the variables rather than just the first empty one. Please can someone point me in the right direction? Thanks Code (csharp): #pragma strict var textureArray : Texture[]; function Start () { for (var i = 0; i < 5; i++) { textureArray [i] = Resources.Load("Test"); } }
I've looked at that already, but can't see how i change the new Texture2D(200, 100); for my Resources.Load("Test");? What is the correct syntax? Thanks
i think you have to set a size before filling it Code (csharp): #pragma strict var textureArray : Texture2D[]; function Start () { var textureArray: Texture2D[] = new Texture2D[5]; // that is what i mean for (var i = 0; i < 5; i++) { textureArray [i] = Resources.Load("Test"); } }
For anyone coming across this with the same problem i had you simply need to add a 'return' to the code. So it only adds once and comes out of the code. Code (csharp): var textureArray : Texture[]; function Start () { for (var i = 0; i < 5; i++) { textureArray [i] = Resources.Load("Test"); return; } }
I don't understand why you would do that...if you just want to set the first texture in the array, there's no point using a loop at all. Making a loop and then returning after the first iteration is extra work for nothing. Code (csharp): textureArray[0] = Resources.Load("Test"); --Eric