Skip to main content

ImageComponent

extends GraphicComponent<ImageComponent> implements ICopyable<ImageComponent>

Description

The ImageComponent is one of the foundational elements of UCGUI.
It makes use of the UnityEngine.UI.Image and offers all kinds of customization options, similar to what you would expect to be able to do with it in the editor.

tip

Take a look at the ImageService to programatically load sprites into your user interface.

Properties

DefaultSize

protected - Describes the default size this image should initialize with. You should propably use Size(float, float) though.

Examples

Simple UI builder
// Returns a simple image, attached to any hierarchy. 
UI.Image(_sprite).Parent(canvas);

// Additional specification of the image type
// in the builder and additional ppum config.
UI.Image(_sprite, Image.Type.Sliced)
.PixelsPerUnitMultipler(0.2f)
.Parent(canvas);
Fluent Pattern!
UI.Image(_sprite)
.Filled(FillMethod.Horizontal, 0.5f) // Defined in ImageComponent
.Color(UnityEngine.Color.purple) // Defined in GraphicComponent
.Alpha(0.1f) // Defined in GraphicComponent
.OffsetX(200) // Global BaseComponent extension
.Parent(canvas); // Global BaseComponent extension

References

This component is referenced or inherited by: AbstractViewComponent, InputComponent, LabelComponent, LayoutComponent, ScrollViewComponent, SliderComponent.

Implementation