I need to activate an RawImage object from javascript but i don’t know the function i need… i try GameObject.Find(“RawImage”).SetActive=true but it gives an error.
This is the error: Expression GameObject.Find(“RawImage”).SetActive cannot be assigned to.
I try with gameObject.SetActive(false) too. I use the function .Find() to find the object “RawImage” and also FindWhitTag (obviusly i give a tag to the object) and i find the error:
NullReferenceException: Object reference not set to an instance of an object
can you give me the complete code to active/deactive the RawImage object in javascript please?
Thank you
RawImage is a component on a gameobject so you’ll have to find or have a reference to the gameobject and then use .GetComponent() to get the reference to the RawImage on that gameobject to then enable or disable it directly. SetActive() is specifically for the gameobject though so if that’s what you want to do you just need the gameobject that the RawImage component is attached to not the RawImage itself. But if you have other components on the same gameobject and the RawImage is really the only thing you what you want to turn on, you would use .enabled = true on the RawImage component.
GameObject.Find() finds by name so you could use it to find the GameObject that has the RawImage attached, just use the name as displayed in the hierarchy for that gameobject.