script 1 [gameobject]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour {
public List<GameObject> Bloques = new List<GameObject>();
static System.Random list = new System.Random();
public Color naranja;
public Color basen;
bool colora = false;
void Awake()
{
int x = list.Next(9);
}
void Update()
{
if (Input.GetMouseButtonDown(0)) {
int x = list.Next(9);
switch (x)
{
case 0:
Bloques[x].GetComponent<Renderer>().material.color = naranja;
colora = true;
if (Cubos.live == true && Bloques[x].GetComponent<Renderer>().material.color == naranja)
{
if (Cubos.color == false && colora == true)
{
Bloques[x].GetComponent<Renderer>().material.color = basen;
}
}
break;
}
}
}
/*public GameObject GetGameObject_FromBloques(string name)
{
foreach (GameObject gameObject in Bloques)
{
if (gameObject.name == name)
{
return gameObject;
}
}
Debug.LogError("Game Object not found in Bloques!");
return null;
}*/
}
other script of each button
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cubos : MonoBehaviour {
public static bool live;
public static bool color;
// Use this for initialization
public void Click()
{
if (Input.GetMouseButtonDown(0)) {
color = false;
}
}
void Update () {
}
}
publics value