How to make an object invisible?

Hi,

Probably it’s a very basic question, sorry for that.

I tried to make an object invisible by disabling in the inspector but when I export the project, I still see the object.

Please refer the attachments for better understanding.

I’m not sure how to make it invisible. I’m very new to Unity, this project was built by someother person.

Please help.

Thanks,
Sudeep


Hey,

What you’ve done is disabled the object completely. No code will run on that object anymore, and it will be invisible.

I suspect that a different object is re-activating it at runtime which is why you can see it.

What you’re actually seeing in the game are not the objects themselves, but the images in the Image components on each of the objects. To make the “Fixed Joystick” invisible, delete the image Component, or uncheck the box next to the Image component on each of the objects that has an image.

You can see one of the Image components in your first screenshot directly to the right of the center red rectangle.

To make something ONLY invisible, disable the thing that is making it visible, usually the Renderer (MeshRenderer, SpriteRender, LineRenderer, UI.Image, UI.Text, etc.)

This still leaves colliders and scripts on it active. You can selectively turn those off the same way, by setting enabled = false; on that thing.

Go read the docs about how collisions and triggers are actually STILL ACTIVE if you only turn off a MonoBehaviour, to allow “waking up” inactive scripts.

To make it completely inactive in scene, set its root GameObject to be .SetActive(false);

And as Unrighteous points out, make sure nothing else is turning it back on.

To make something go away, Destroy() it.

1 Like

Thank you for your responses.

I have deleted the sprite as you suggested but now I see a white patch. Not sure where it went wrong. Can you help me with how to remove the white patch?

Thank you.

7534019--930263--2021-09-30.jpg

Hey,

You need to remove the Image component, not remove the sprite from the Image component. Right click on the Image component, and press “Remove Component.”