c# - Empty Array in Unity? -
i'm working on bit of brute force workaround bug in program, because there doesn't seem way refresh values assigned in editor. anyway, i'm trying load images (sprites) array script can use. however, doesn't seem working , i'm not sure why. i've not done stuff before made simple mistake. error saying pics1[i] out of range. here code below:
using unityengine; using system.collections; public class imageblock : monobehaviour { public sprite[] pics1; public static sprite[,] allpics; // use initialization void start () { pics1 = resources.loadall<sprite> ("dock pics"); allpics = new sprite[100,100]; (int = 0; pics1 [i] != null; i++) { allpics [1,i] = pics1 [i]; } }
}
change for-loop this:
for(int = 0; < pics1.length; i++)
that might trick. if check pics1[900] not return null, throw indexoutofrangeexception, why want check existing indices beforehand. of course within valid range pic1[i] may return null, if index defined, no element assigned.
Comments
Post a Comment