- Home /
Make an Array of Arrays of Textures
Hi guys and gals, this is a tricky question. My goal is to have a folder that has subfolders filled with PNG images. So, this is how I thought I'd approach it...
Make an array. Inside the array is arrays of textures. So, for example, the first array would be filled with 3 images. These would be exported to the directory "Theme 1" and then move on to the next array, these images would be exported to directory "Theme 2." I have the saving script done, and it changes Texture or Texture2D into .png images and saves them where I want, but I cannot figure out the best way to separate the themes.
I'm using UnityScript. I know you can use System Lists to do this, but then you cannot assign them in the navigator, which makes for lots more coding. Arrays you can simply point and click in the navigator and it assigns them very conveniently, and you can add or remove them with ease.
I've Google'd around and found you can, in normal Javascript, do it simply by having double brackets... so Texture[][]
but in Unity, this just results in an error.
I'm stumped here and would love a bit of input. Thanks!
You can definitely assign Lists in the inspector. So, do that.
In program$$anonymous$$g terms, what you're looking for is termed a "jagged array". That might aid your Google-fu.
How do you declare it correctly as a list then to be able to use it in the inspector? I can't get it to come up.
I will google jagged array, thanks!
I did it like this, and now I can assign it in the navigator, but it is no different than the array... for each listing, I wanted another array. If I do
List.<Texture2D[]>
it disappears from the navigator...
Answer by justinl · Apr 04, 2013 at 10:32 PM
I've used this structure before in Unity to give me multi-dimensional arrays in the Unity editor. It works pretty well: Visualizing a Multi Dimensional Array
I got this working... do you happen to know how to iterate through all of the variables? Thanks for the help!
I'd imagine it would be something like this (untested): foreach($$anonymous$$ultiDimensionalInt the$$anonymous$$ultiArray in the$$anonymous$$ultiDimensionalIntArray){ foreach(int i in the$$anonymous$$ultiArray.intArray){ Debug.Log(i);//here is a value in one of the arrays} }
I'll give it a shot... I posted another question before I got this answer, so maybe someone else can confirm. If you'd like to post this in there as well I can mark it correct if so.