Which is the correct code to do it?
I ve used gameObject.GetComponent(“RawImage”).enabled=true;
but it gives an error of null reference why?
Thank you very much
I’m assuming you’re using javascript.
gameObject.GetComponent(“RawImage”).enabled=true;
This won’t even compile for me so I don’t know how you get a null reference that way.
It will work this way:
gameObject.GetComponent(RawImage).enabled=true;
This also works:
var _rawImage : RawImage = gameObject.GetComponent(“RawImage”);
_rawImage.enabled = true;
But if any of those give null references then you probably have your script on the wrong gameobject, it needs to be the same object that has the RawImage.
oh yes i have put the script on the FirstPersonController… But first the rawImage have to be disenabled, then when i active a collider it have to enabled, so i can’t put the script on the RawImagew… how can i change it from another object? thaks