- Home /
Question by
k_h · Feb 03, 2014 at 01:08 AM ·
gameobject.findrenderer.enabled
No renderer.enabled=false on grouped GameObject
Hi everyone, if some of my Gameobjects are grouped in the hierarchy "GameObject.renderer.enabled = false;" is not working. I just want hide some objects if the mouse is over an object. Is there anybody who can explain that to me? Im still a beginner on Unity and in some points I dont understand the software. Here is my code snippet:
#pragma strict
var group1 : GameObject;
var group2 : GameObject;
function Start() {
group1 = GameObject.Find("GameObjectGroup1");
group2 = GameObject.Find("GameObjectGroup2");
}
function OnMouseOver() {
group1.renderer.active = false;
group2.renderer.active = true;
}
function OnMouseExit() {
group1.renderer.active = true;
group2.renderer.active = false;
}
it would be great if some of you have me some answers. thanks!
Comment
Best Answer
Answer by ffxz7ff · Feb 03, 2014 at 02:12 AM
group1.GetComponent<Renderer>().enabled = false;
This should work. Or simply
group1.active=false;
I believe the latter solution deactives the Collider and everything too though.
Answer by k_h · Feb 03, 2014 at 02:23 PM
it works. thank you very much! I just need more time to handle with unity;)