Called when the button is clicked.
Called when an image set by setImage or setImageURL is done loading. This will be within the call if the image is already cached, or some time later if the image has to be loaded first. Not called if the image can't be loaded. Note that if you call set the image before setting this callback, it might not get called because the image has been loaded instantly if it was cached.
Get the height of the displayed image file. Does not have to be identical to the desired height of the image, use getImageHeight for that. Returns 0 if no image has been set or it hasn't been loaded yet. Wait for onImageLoaded before using this method to ensure that the size from the loaded file is available.
Get the width of the displayed image file. Does not have to be identical to the desired width of the image, use getImageWidth for that. Returns 0 if no image has been set or it hasn't been loaded yet. Wait for onImageLoaded before using this method to ensure that the size from the loaded file is available.
Get the desired width of the image, as set by setImageSize
Get the desired width of the image, as set by setImageSize
Return the game object that this UI element is attached to. Returns undefined if the element isn't attached to a game object.
Return the widget that contains this widget, for example a border that wraps a check box. Returns undefined if this object has no parent.
Return the current tint color of the image
Return whether the widget is currently enabled (see setEnabled).
Return whether the widget is currently visible (see setVisible).
Set whether the widget is enabled. When a widget is disabled, users can't interact with it and it is greyed out. When a widget that contains other widgets (like VerticalBox) is disabled, all its children behave as if disabled, too. By default, widgets are enabled.
Whether to enable the widget.
Set the displayed image file. When an image is used for the first time, it is loaded in the background and won't be visible immediately. onImageLoaded is called when the image is loaded.
The filename of the image to load
The id of the package that contains the image file (in the Textures folder). Can usually be empty when used from scripts to use the same package that contains the script file, but you need to explicitly pass refPackageId for the current package or a package id when you use it in a callback. You can find package ids in the manifest.json file in package folders. Usually you won't use this parameter, unless you have a specific reason to load an image from a different package than where the script is located.
Set the desired size of the image. If both axes are set to 0, the size will be the actual size of the image file. If only one axis is set to 0, it will be set to a value that preserves the aspect ratio of the image, and the other value above 0 will be fixed. Desired size can get overridden by the widget size on a Canvas or the size of the UIElement when the image is the only widget and UIElement.useWidgetSize is false. The button has two pixels of padding around the image on all sides, so the total size of the button will be four pixels larger on each axis.
Desired width of the image. Default: 0
Desired height of the image. Default: 0
Set the displayed image file from a URL
The filename of the image to load
Set the displayed image based on a card. The image file width will always be 128, the file height is calculated based on the aspect ratio of the card. Note that if the card is deleted or becomes part of another stack, the image widget will become empty when it is reloaded, for example because the containing UI is changed or for a new player who joins.
The card that should be displayed on the widget.
Set the tint color of the image. Default: White
Set whether the widget is visible. When a widget that contains other widgets (like VerticalBox) is invisible, all its children are invisible, too. The layout of widgets is updated when visibility changes, and invisible widgets are treated as if they don't exist.
Whether the widget is visible.
A UI button displaying an image.