var side : int = 20;
var butDim : int = 128;
function OnGUI(){
for(var i = 0; i < side; i++){
for(var j = 0; j < side; j++){
if(GUI.Button(Rect( (i*butDim), (j*butDim), butDim, butDim), "")){
//do something....
}
}
}
}
This simple script generate a matrix of GUI.Button.
When I press a casual button inside this matrix I’d like to disable it without disable all the others buttons, but I can’t.
Can someone help me please?
Thanks in advance.
Ryan
can’t help you with your unity script, however heres how it could be done in c#
using UnityEngine;
using System.Collections;
public class buttonMonster : MonoBehaviour {
int side = 20;
int butDim = 50;
bool[,] buttonBools;
// Use this for initialization
void Start () {
buttonBools = new bool[side,side];
for( int x = 0; x < side; x++ )
{
for( int y = 0; y < side; y++ )
{
buttonBools[x,y] = true;
}
}
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
for( int x = 0; x < side; x++ )
{
for( int y = 0; y < side; y++ )
{
if(buttonBools[x,y])
{
if(GUI.Button( new Rect( x * butDim, y * butDim, butDim, butDim ), "Button" )) buttonBools[x,y] = !buttonBools[x,y];
}
}
}
}
}
It requires two dimensional array of booleans to work.
Are you doing minesweeper? 
Thank you very much Rouhee.
Your code works perfectly!!
Thank you again.
Ryan
P.S.
I’m doing something like Sudoku