Unity Spain
Post Antiguos => General (Antiguo) => Mensaje iniciado por: berserker en Diciembre 09, 2015, 08:04:00 PM
hola lo que busco es simple , pulsando un GUI botón que aparezca y desaparezca un gameobjet como un cubo etc.este código me sirve para conseguirlo pulsando un botón del teclado "q", pero quiero conseguirlo con un gui botón de pantalla:using UnityEngine;
using System.Collections;public class EnableDisableGameObject : MonoBehaviour
{
public GameObject cubo;
public void Start()
{
cubo = GameObject.Find("Cube"); } public void Update()
{
if(Input.GetKeyDown("q"))cubo.SetActive(false); if(Input.GetKeyDown("w"))cubo.SetActive(true);}} tendré que asignarle el script a el botón UI ,pero no se que función es la que debo usar para conseguirlo.os dejo el video de donde he sacado el código: https://www.youtube.com/watch?v=2USGWNS3dcU (//%5Byoutube%5Dhttps://www.youtube.com/watch?v=2USGWNS3dcU%5B/youtube%5D) un saludo y gracias.
using UnityEngine;
using System.Collections;
public class des : MonoBehaviour {
public GameObject cubo;
// Use this for initialization
// Update is called once per frame
public void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
cubo.gameObject.SetActive(false);
}
if (Input.GetKeyDown(KeyCode.W))
{
cubo.gameObject.SetActive(true);
}
}
}