How do I save a three dimensional array?

Hi, I would like to save a three dimensional string array.

I just worked with the standard playerprefs and am not familiar with saving data.
The array contains profile and character information, so it shouldn’t be readable by others or manipulated easily.
The array should be loaded just once at the beginning of my programm.

I already looked at ArrayPrefs2, but that script just saves simple arrays.

Has somebody a nice link or solution for me, would really appreciate it :slight_smile:

I don’t use PlayerPrefs for saving because of the possible errors when file size gets too long, but I can give you the actual sorting code for transforming your array to one dimension and back.

I have an int[,] array for blocks (voxel), and save them in a long list of ints for saving (blockList). For strings, it there wouldn’t be any difference I think :slight_smile:

 for(int x = 0; x < xSize; x ++) {
      for(int y = 0; y < ySize; y ++) {
       for(int z = 0; z < zSize; z ++) {

                blockList.Add (blockData[x,y,z]);
       }
  }
 }

For loading it’s more complicated and it took me a long timeto figure it out:

 int x = 0;
 int y = 0;
 int z = 0;
 for(int i = 0; i < blockList.Count; i ++) {

      blockData[x,y,z] = blockList*;*
  • z++;*
    
  • if (z == zSize) {*
    
  •     z = 0;*
    
  •     if(y < ySize - 1) {*
    
  •          y++;*
    
  •     }*
    
  •     else {*
    
  •          x++;*
    
  •      y = 0;*
    
  •     }*
    
  • }*
    

}