Hey Guys, I tried to use multidimensional arrays in boo and it just threw this error:
NullReferenceException: Object reference not set to an instance of an object GameScript.buildGrid () (at Assets/Scripts/GameScript.boo:28) GameScript.OnGUI () (at Assets/Scripts/GameScript.boo:40)
Here’s my Code:
import UnityEngine public class Card (System.Object): isFaceUp as bool = false isMatched as bool = false public img = "robot" class GameScript (MonoBehaviour): cols as int = 4 rows as int = 4 totalCards as int = cols * rows matchesNeededToWin as int = totalCards * 0.5 mathesMade as int = 0 cardW as int = 100 cardH as int = 100 aCards as List aGrid as (Card, 2) aCardsFlipped as List playerCanClick as bool playerHasWon as bool = false def buildGrid(): GUILayout.BeginVertical() for i in range(rows): GUILayout.BeginHorizontal() for j in range(cols): card = aGrid[i,j] if (GUILayout.Button(Resources.Load(card.img), GUILayout.Width(cardW))): Debug.Log(card.img) def Start (): playerCanClick = true for i in range(rows): for j in range(cols): aGrid[i,j] = Card() def OnGUI (): GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height)) //buildGrid() GUILayout.EndArea()
Thanks in advance!