Reputation: 63
In my game I have a empty gameobject that has a sprite and a textmesh as child I want to access the sprite and the text mesh and turn off the sprite renderer and mesh renderer of the sprite and the text mesh programmatically & then turn it on. How?
Upvotes: 0
Views: 2601
Reputation: 7824
All you need is a reference to the GameObject
that contains one of these components.
Example of how to find a GameObject in the scene.
var obj : GameObject = GameObject.Find("Name Of GameObject in Scene");
Example of how to disable the renderer.
obj.renderer.enabled = false;
Upvotes: 0