0
votes

I got some problem. I am trying to hide aGameObject using SetActive(false); But the object is still shown in the game.

Here is the code:

public class test : MonoBehaviour {

    public GameObject a;
    public GameObject b;


    void Start () {
        a.SetActive (false);
        b.SetActive (false);
    }
}
1
Are you sure that SetActive (true); is not being from another Update function? - Programmer
Ok. Can you post a picture/screenshot that shows your object a and b and the slot on the script they are connected to. I've never seen a problem like this before... - Programmer
I just have solved the problem. I created empty object and set object A to child. Thanks a lot - Ruslan _Big
glad you solved it - Programmer

1 Answers

0
votes

(Going off some presumptions here, please correct if this is not your scenario)

In order for this to work, a and b will need to be GameObjects in your actual scene. This will not work with prefabs because prefabs aren't ever in the scene, they're copied in.