- Home /
Question by
JungDuckSoo · Sep 13, 2011 at 05:30 AM ·
bytearray
Invalid rank specifier error
When I build this script, an error occured. I try to solve it myself, but I can't. please help me.
using UnityEngine;
using System.Collections;
public class Game : MonoBehaviour {
byte[] tilePosX;
byte[] tilePosY;
byte[] tilePosZ;
int tileTotalNumber;
int layoutRowsX,layoutRowsY,layoutRowsZ;
int[][][] tileLayoutIndex;
int[] layoutZStart;
int[] layoutZStop;
void Start () {
}
void Update () {
}
void loadlayout(int level)
{
TextAsset ta = Resources.Load("lev.lay", typeof(TextAsset)) as TextAsset;
byte[] bytes = ta.bytes;
int offPart1 = bytes[2*level];
int offPart2 = bytes[2*level+1];
if(offPart2 < 0){
offPart2 += 256;
}
int offset = offPart2|(offPart1<<8);
tileTotalNumber = bytes[offset+0]+128;
layoutRowsX = bytes[offset+1];
layoutRowsY = bytes[offset+2];
layoutRowsZ = bytes[offset+3];
tilePosX = new byte[tileTotalNumber];
tilePosY = new byte[tileTotalNumber];
tilePosZ = new byte[tileTotalNumber];
for(int i= 0; i < layoutRowsX; i++)
{
tileLayoutIndex[i] = new int[][layoutRowsY]; --> Invalid rank specifier: expect-
-ed ',' or ']' . Array creation must have array size or array initializer.
for(int j = 0; j < layoutRowsY; j++)
tileLayoutIndex[i][j] = new int[layoutRowsZ];
}
for(int x=0; x<layoutRowsX; x++){
for(int y=0; y<layoutRowsY; y++){
for(int z=0; z<layoutRowsZ; z++){
tileLayoutIndex[x][y][z] = -1;
}
}
}
for(int i=0; i<tileTotalNumber; i++){
tilePosX[i] = bytes[offset+4+i*3];
tilePosY[i] = bytes[offset+4+i*3+1];
tilePosZ[i] = bytes[offset+4+i*3+2];
tileLayoutIndex[tilePosX[i]][tilePosY[i]][tilePosZ[i]] = i;
}
layoutZStart = new int[layoutRowsZ];
layoutZStop = new int[layoutRowsZ];
int tempZIndex = 0;
for(int i=0; i<tileTotalNumber; i++){
if(tilePosZ[i] != tempZIndex){
layoutZStart[tilePosZ[i]] = i;
layoutZStop[tilePosZ[i]-1] = i-1;
tempZIndex = tilePosZ[i];
}
}
layoutZStart[0] = 0;
layoutZStop[layoutRowsZ-1] = tileTotalNumber-1;
bytes = null;
}
}
Comment
facepalm *
and the error is ???
Sorry, pet peeve of $$anonymous$$e when people post "Hey I got an error, but I'm going to make you guess what it is."