- Home /
Question by
ChocoMan · Apr 21, 2016 at 09:16 PM ·
unity 5gameobjectmouseclickonclick
How to make when object is pressed, object2 does something?
I have a script applied to object and when itself is clicked, it goes invisible. But then when an object next to it have it clicked, it reappears, our maybe a button when its clicked it reappears. Is it possible? this script is component of the disappearing GameObject.
using UnityEngine;
using System.Collections;
public class Inviisble : MonoBehaviour {
void Start () {
}
void Update () {
}
void OnMouseDown(){
GetComponent<Renderer>().enabled = false;
}
GameObject gos = GameObject.FindGameObjectsWithTag("Sphere");
void OnMouseDown(gos){
GetComponent<Renderer>().enabled = true;
}
}
this is what i have in gameobject when its clicked, disappears.
Edit: Actually I have a GUI button on top left of the screen and it would be better if the button is clicked, reappear Object?
Comment
Edit2: Ok I have solved it, I entered a public call in the script of the GameObject to reappear, and in button Inspector, onClick I attached the GameObject and selected the call function. and it is done :D
Your answer
![](https://koobas.hobune.stream/wayback/20220612075333im_/https://answers.unity.com/themes/thub/images/avi.jpg)