- Home /
Finding position of button in guilayout grid
How do I find the exact position of a button in this GUILayout grid: var aGrid:Card[,] = new Card[4,4];
var cols:int = 4;
var rows:int = 4;
function BuildGrid()
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
for(var i:int=0; i<rows; i++)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
for(var j:int=0; j<cols; j++)
{
var card:Card = aGrid[i,j];
if(card.isFaceUp)
{
img = card.img;
}else{
img = "faceup";
}
}
GUI.enabled = !card.isMatched;
GUILayout.Button(Resources.Load(img), GUILayout.Width(sixthOfScreenW), GUILayout.Height(sixthOfScreenH))
GUI.enabled = true;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
//This is the Card class
class Card extends System.Object{
var isFaceUp:boolean = false;
var isMatched:boolean = false;
var img:String;
var id:int;
function Card(img:String, id:int){
this.img = img;
this.id = id;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to get a control position on a guilayout? 2 Answers
Unity android- GUILayout button not showing text? 1 Answer
How do i get the UI button position? 2 Answers
GUI Repeat Button problem 1 Answer
GUILayout.button size is not changin 2 Answers