Build that grid
Between the area statements, we want to build the grid of card buttons. But, to keep the code from getting hard to understand, we could make a function call out to a separate piece of code, just to keep things looking clean and easy to read. Modify your OnGUI
code:
function OnGUI () { GUILayout.BeginArea (Rect (0,0,Screen.width,Screen.height)); BuildGrid(); GUILayout.EndArea(); print("building grid!"); }
That building grid!
line is just so that you can be sure something's happening. I like to add statements like these so that I can see into the "mind" of my computer, and to make sure certain functions are getting executed. Remember that your print
statements show up in the status bar at the bottom of the screen or in the console window if you have it open.
Tip
Note that if we actually try to run the code now, we'll get an error. Unity has no idea what the BuildGrid
function is, because we haven't written it yet!
Let's write that BuildGrid
function. Add this code...