Forum rules - please read before posting.

Hiding image in Document UI

I've put together a Unity UI for reading documents, including a little box that holds the article's image. My plan has been to hide this box when the document being read contained no image, to allow the text area to expand using a horizontal layout group.

So, I put together a script that checks, if the sprite is "null", to hide the frame that holds the image. I tested it with two documents - one with an image, one with none. If I open the pictureless document first, it works perfectly - the image frame disappears, and the text fills the gap.

But, after opening the document with the graphic, the "null" check no longer seems to work, as the UI keeps bringing up the image from the previous document that did have an image.

I imagine that one way around this would be to check whether the document currently open has an image associated with it, rather than checking the UI to find out whether there's an image being used.

Essentially: is there a way to find out which document is currently open in the UI?

Comments

  • But, after opening the document with the graphic, the "null" check no longer seems to work, as the UI keeps bringing up the image from the previous document that did have an image.

    This sounds like a bug, so I will look into this. However, the active document texture can be read separately with:

    KickStarter.runtimeDocuments.ActiveDocument.texture
    
  • Thank you, my script is now working exactly as intended!

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.