- Home /
Question by
JazzAKD08 · Jul 31, 2017 at 11:13 PM ·
androidaugmented-reality
Disable cubes
Hi!
Please i'm in trouble i have this cubes, but I need that when I press over one the rest must be deactivated, For example if I press "ch" the rest must be desactivated except the "Siguiente" text.
There is a part of the Script that I use:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ChadoScript : MonoBehaviour {
//public GameObject cubes;
// Use this for initialization
public int scoreAmount = 0;
public string letra = "";
int scorePP=0;
int scoreFinal=0;
//string arr = new string [] {"A"};
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
Destroy(hit.collider.gameObject);
}
if (hit.collider.tag == "Letra_ch")
{
//Debug.Log(hit.collider.tag);
scoreAmount++;
letra="ch";
if (GameManager.gm) {
GameManager.gm.targetHit (scoreAmount);
}
scoreFinal= PlayerPrefs.GetInt ("Score", scorePP)+scoreAmount;
PlayerPrefs.SetInt ("Score", scoreFinal);
Debug.Log ("Score en ch: " + scoreFinal);
Debug.Log ("ESTOY EN CH EN SCRIPT: " + letra);
PlayerPrefs.SetString ("Chado", letra.ToString());
}
whatsapp-image-2017-07-27-at-203021.jpeg
(102.3 kB)
Comment
Answer by Y00 · Aug 02, 2017 at 12:29 PM
cube1.SetActive(false); cube2.SetActive(false); ....
Create a links (GameObject cube1, cube2 ...) yourself
keep all cubes in a list when you create them, so you can easilly do this.