Selection-Grid
From Unify Community Wiki
Author: Bérenger
Description
makes a grid using a texture of your choice
Usage
get / make a texture representing your buttons.
//this example uses a texture2d of x = 12 squares and y = 12 squares, i made the texture 360 but it turned to 240 in button so each button is 20 pixels. var style1 : GUIStyle;//empty style to make no button borders. function OnGUI(){ var gridpixels = 20;//pixels per grid square var gidxsquares = 12;//num squares in x direction if (GUI.Button(Rect(320,10,240,60),fctbutton,style1)) { var xpos = Input.mousePosition.x - 320 ; var ypos = Screen.height - Input.mousePosition.y -10; var result = Mathf.Floor(xpos / gridpixels) + Mathf.Floor(ypos / gridpixels)*gidxsquares + 1;//plus 1 at end for not zero first square // print (result); } }