I am trying to create a multislot inventory like a grid it works for 2*2 or if the length is just 2 but if the length is bigger it doesnt create the whole thing here is the script so far any help or suggestions.
public int gridWidth;
public int gridLength;
public float SlotSize;
public float gridStart;
public GUITexture Slot;
private float currentGridW;
private float currentGridL;
private int f;
void Awake(){
currentGridW = gridStart;
currentGridL = gridStart * 2f;
f = 2;
for (int i = 0; i < gridWidth; i++) {
float newGridW = currentGridW;
GUITexture gridW;
gridW = Instantiate (Slot) as GUITexture;
gridW.pixelInset = new Rect (newGridW, 0f, SlotSize, SlotSize);
gridW.name = "Slot " + 0 + "," + i;
currentGridW += SlotSize;
if (gridWidth >= 1){
for (int g = 0; g < gridLength - 1; g++) {
float newGridL = currentGridL;
GUITexture gridL;
gridL = Instantiate (Slot) as GUITexture;
gridL.pixelInset = new Rect (newGridW, newGridL, SlotSize, SlotSize);
gridL.name = "Slot " + i + "," + (g + 1);
if(gridLength - 1 >= f){
currentGridL += SlotSize;
f = f + 1;
}
}
}
}
}
void Update(){
Debug.Log (f);
}
}