Hi there, I am new to unity and I’m looking for a way to bring in a 2d array from a outside text file into unity then processing the information. I did it with java but Im not sure how to do it in unity on account that I don’t know much about C#. I want to read a file full of listed arrays for example:
1,0,0,1,0,1,0,1,0
1,0,0,1,0,1,0,1,0
1,0,0,1,0,1,0,1,0
1,0,0,1,0,1,0,1,0
1,0,0,1,0,1,0,1,0
ect. up to 3000 lines
Is there something in C# like a buffered reader in java that can do this? Also I heard that Unity has something called a Jagged Array which is similar to a 2d array but not constrained to a single length. For what I am doing I know I need 8 indexes, but a variable amount of indexes down. Again I have no idea how to do this, any help would be great. This is my java code if that helps:
FileReader ConnectionToFile = new FileReader(filename);
BufferedReader reader = new BufferedReader(ConnectionToFile);
int[][] spaces = new int[10][10];
String line = null;
int row = 0;
while ((line = reader.readLine()) != null)
{
String[] array = line.split(",");
for (int i = 0; i < array.length; i++)
{
spaces[row] _= Integer.parseInt(array*);*_
* }*
* row++;*
* }*
I then plan to go through each array row saying:
if(spaces[row][1] ==1)
{
do something
]
else if(spaces[row][1] ==0)
[
do nothing
]
if(spaces[row][2] ==1)
{
do something
]
else if(spaces[row][2] ==0)
[
do nothing
]
ect…