Forum rules - please read before posting.

Hide Unity UI image when the associated text is empty

Merry Christmas!

I'm using a Unity UI in Prefab for my Hotspots menu, and my TMPro text object is a childobject of my Image Gameobject - which acts as a background for this text. The text is linked to AC's menu and updates correctly according to the specified Hotspot label.

Only, I have a few hotspots which have no label (intended) As recommended elsewhere here, I've forced these to be empty by pressing Space once.

This successfully hides the text from the Hotspot text element, but the background image continues to show.

Is there any existing way around this? Or maybe a new "Graphic type" option in the Graphic Element type option in the AC menu which allows you to link it to a text field and turn it off if the associated text string is empty/space?


  • You could attach a script to it that sets its "enabled" state based on the contents of the Text box, i.e.:

    public TMPro.TextMeshProUGUI uiText;
    public UnityEngine.UI.Image uiImage;
    void LateUpdate ()
        uiImage.enabled = !string.IsNullOrEmpty (uiText.text);
  • Thanks! Works after changing it to IsNullOrWhiteSpace

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.