- Home /
Make an object invisible
Hello, I'm trying to make my object invisible on startup. I found code on the Unity resources explaining to use a javascript script containing this code:
renderer.enabled = false;
function Update () {
}
However, this does not work.
Answer by Lo0NuhtiK · Dec 20, 2011 at 12:11 AM
Do you have the script attached to the object which has a mesh renderer? If you do, renderer.enabled = false, even with absolutely nothing else on the script, should disable the renderer. If its not attached to the object , then you're going to have to tell it which objects renderer to disable.
It is directly attached to the object. I even tried putting that line of code in the update function, but it returned compiler errors.
I have no idea what's wrong then. Works fine for me. All I can figure is that you might have it attached to a parent, but a child is the one with the renderer.
Hi kmccmk9 what was the compiler error when you put it into the update function?
It honestly wouldn't give me one. $$anonymous$$aybe I do have it attached to a parent. I will try putting it on other sub objects.
Answer by markl · Dec 20, 2011 at 12:42 AM
I'd say it needs to be in the Update
function Update () {
renderer.enabled = false; }