Hi everyone. I’m doing the Robot Repair tutorial game in Unity3D Game Development by Example but I’m running into a problem early on and can’t figure out what’s causing it.
I’m getting the error “Type ‘Object’ does not support slicing.” but my code looks the same as the code in the book.
#pragma strict
var customSkin:GUISkin;
var cols:int = 4;
var rows:int = 4;
var totalCards:int = cols*rows;
var matchesNeededToWin:int = totalCards * 0.5;
var matchesMade:int = 0;
var cardW:int = 100;
var cardH:int = 100;
var aCards:Array; //Store the cards we create in this array
var aGrid:Array; //This array will keep track of the shuffled, dealt cards
var aCardsFlipped:ArrayList; //This array will sstore the cards the player flips over
var playerCanClick:boolean;
var playerHasWon:boolean = false;
function Start(){
playerCanClick = true;
aCards = new Array();
aGrid = new Array();
aCardsFlipped = new ArrayList();
for(var i=0;i<rows;i++){
aGrid*= new Array();*
-
for(var j=0;j<cols;j++){*
aGrid_[j] = new Card();_
* }*
* }*
}
function Update () {
}
function OnGUI(){
* GUI.skin = customSkin;*
* GUILayout.BeginArea(Rect(0,0,Screen.width,Screen.height));*
* BuildGrid();*
* GUILayout.EndArea();*
* print(“Building grid”);*
}
function BuildGrid(){
* GUILayout.BeginVertical();*
* for(var i=0;i<rows;i++){*
* GUILayout.BeginHorizontal();*
* for(var j=0;j<cols;j++){*
var card:Object = aGrid_[j];
* if(GUILayout.Button(Resources.Load(card.img),GUILayout.Width(cardW))){
Debug.Log(card.img);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}*_
class Card extends System.Object
{
* var isFaceUp:boolean = false;*
* var isMatched:boolean = false;*
* var img:String;*
function Card(){
* img = “model”;*
}
}