Quantcast
Viewing latest article 22
Browse Latest Browse All 99

Gameobject with many child objects disable mesh not working.

Hi guys, Now this is already a discussed topic and I still did not get how to solve the issue. Problem: I have an architectural building with many child game objects in it. Some having renderer and some gameobjects(without renderer) having further child objects which in return has more children. So I want to make the whole building invisble in a click of Button1 and make it visible again on clicking Button2. I have written the following code but it does not works. using UnityEngine; using System.Collections; public class ActionScriptChangeVisibility: MonoBehaviour { public Renderer[] objectHavingChild; public void InvisibleBeacon() //Button1 { objectHavingChild = GetComponentsInChildren(); foreach (Renderer rend in objectHavingChild) rend.enabled = false; } public void VisibleBeacon() //Button2 { objectHavingChild = GetComponentsInChildren(); foreach (Renderer rend in objectHavingChild) rend.enabled = true; } } Question: This script is attached to the buttons. I don't get how to disable a particular parent game object along with child. How do I make the whole building invisible? In this code there is no option to select the particular gameobject to make it invisble. Any help is appreciated. Thanks in Advance.

Viewing latest article 22
Browse Latest Browse All 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>