static public bool load (byte [,,] data, Vector3 pos, string fileName)
{
if (data == null)
{
Debug.Log("Data is null.");
return false;
};
if (!File.Exists(fileName))
{
Debug.Log("File '" + fileName + "' doesn't exists.");
return false;
};
BinaryReader br = new BinaryReader(File.Open(fileName, FileMode.Open));
if (br == null)
{
Debug.Log("BinaryWriter creation failed.");
return false;
};
pos.x = br.ReadSingle();
pos.y = br.ReadSingle();
pos.z = br.ReadSingle();
int length = br.ReadInt32();
int width = br.ReadInt32();
int height = br.ReadInt32();
if (data.GetLength(0) != length || data.GetLength(1) != width || data.GetLength(2) != height)
{
Debug.Log("Invalid array size.");
return false;
};
for (int i = 0; i < length; i++)
{
for (int j = 0; j < width; j++)
{
for (int k = 0; k < height; k++)
{
data[i,j,k] = br.ReadByte(); Debug.Log(data[i,j,k]);
};
};
};
br.Close();
return true;
}