I am still a bit new to c#/unity, and I would like to dynamically create a 2d char array. So I have an object(levelLoader) with a mostly working script below.
This is functional, but is not dynamic, and a massive kludge. Is can someone help me out?
The text file is nothing by simply chars with a end of line char '/n' ... thoughts?
asked Feb 25 '11 at 09:49 PM
I'd probably store the size of the mapMatrix you required inside the mapFile.txt up the top as some form of meta data. You could then just grab the dimensions first thing after opening the file and create the array.
Otherwise you'll probably need to use some form of container
Personally never used a multidimensional array for anything but small data that requires very quick processing. I find the functionality and cleanness of a container much more convenient. You do lose the ability to use multiple dimensions but finding the required index from a x/y value is easy as y * width + x;
answered Feb 25 '11 at 10:17 PM
Well, in your case I would suggest to use a string array (or maybe a List )instead ot your 2-dimentional char array:
If you need more information in one cell I would use a
answered Feb 26 '11 at 12:25 AM