void OnSelect() { Transform[] lista = new Transform[1 + this.lista.Count]; GameObject prensa = GameObject.Find("Prensa"); //Prensa prensaScript = prensa.GetComponent<Prensa>(); Array.Clear(lista, 0, lista.Length); lista = this.lista.ToArray(); GameObject cubeFrente = GameObject.Find("CubeFrente"); ButtonFrente cubeFrenteScript = cubeFrente.GetComponent <ButtonFrente>(); cubeFrenteScript.f = false; cubeFrenteScript.flag = false; for (j = 0; f == false && j < lista.Length; j++) { if (lista[j].gameObject.activeInHierarchy) { f = true; } } if (!flag) { if (!f) { if (lista.Length != 0) { cont = lista.Length - 1; flag = true; } else { cont = 0; } } else { cont = j - 2; flag = true; } } if (lista.Length > 0) { if (cont == lista.Length - 1) { lista[0].gameObject.SetActive(false); } if (cont >= 0 && cont != lista.Length - 1) { lista[cont + 1].gameObject.SetActive(false); } lista[cont].gameObject.SetActive(true); if (cont == 0) { cont = lista.Length; } cont--; } }
//Input para gestos void OnSelect() { GameObject cubeTras = GameObject.Find("CubeTras"); cubeTrasScript = cubeTras.GetComponent <ButtonTras>(); GameObject cubeFrente = GameObject.Find("CubeFrente"); cubeFrenteScript = cubeFrente.GetComponent <ButtonFrente>(); if (flag) { obj.SetActive(false); flag = false; } else if (flag == false) { obj.SetActive(true); flag = true; } cubeFrenteScript.lista.Clear(); cubeTrasScript.lista.Clear(); if (cubeFrenteScript.cont != 0 && GameObject.Find("Prensa" + cubeFrenteScript.cont) != null) { GameObject filho1 = GameObject.Find("Prensa" + cubeFrenteScript.cont); filho1.gameObject.SetActive(false); } if (cubeTrasScript.cont == cubeTrasScript.lista.Count) { if (cubeTrasScript.cont != 0 && GameObject.Find("Prensa" + cubeTrasScript.cont) != null) { GameObject filho2 = GameObject.Find("Prensa" + cubeTrasScript.cont); filho2.gameObject.SetActive(false); } } else { if (cubeTrasScript.cont != 0 && GameObject.Find("Prensa" + (cubeTrasScript.cont + 2)) != null) { GameObject filho2 = GameObject.Find("Prensa" + (cubeTrasScript.cont + 2)); filho2.gameObject.SetActive(false); } } if (!f2) { var numPrensa = 1; foreach (Transform child in grid.transform) { if (child.name.Equals("Prensa" + numPrensa)) { numPrensa++; cubeFrenteScript.lista.Add(child); cubeTrasScript.lista.Add(child); } } f2 = true; } else { f2 = false; } Debug.Log("count lista: " + cubeFrenteScript.lista.Count); }