Forum rules - please read before posting.

Change object visibility using script?

I need to set an object to visible but I won't know what object until a script is run to find out.

I figured I could use GameObject.Find using a variable with the name of the object but I've not had any luck with SetActive(true) or GetComponent().enabled = true.

Comments

  • The GameObject will need to be enabled in order to find it - you're best off keeping it active, but disabling its Renderer component. If your script has a reference to the GameObject, you can enable it with:

    myGameObject.GetComponent<Renderer> ().enabled = true;
    
  • I just spent a good hour trying to get this to work without any success...

    Turns out I had the OnStart making the object visible then hiding all of the objects in the parent, instead of hiding them all first then making the one I want visible 🤦

    Thank you so much for your help though!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.