disable canvas component..how to?? (solved)

hi i 'm trying to disable a canvas component called StaminaBar taht i would it disappear when my player enter in water…

i managed to make stamina script stops to work and reactivate it when my player is out of water but stamina bar component reamin onscreen when player is in water and it’s weird …

i tried with

Canvas.GetCompoent().SetActive = false;

but obviouslyt this hide all canvas and i only want to hide StaminaBar component form Canvas Gameobject
any help is appreciated

It would be weird if code that didn’t compile hides all canvases…

If you just want to disable one thing in the Canvas, use a CanvasGroup, which can control the enabled state and opacity of all objects beneath it in the hierarchy.

1 Like

A canvasgroup is a good idea. You can of course just disable the game object, also, with a reference to it in some other script (that could also re-enable it when you’re out of the water).

cool thanks … i solved with CanvasGroup…

could mark topic as Solved…