Elements
Image
An image display element for showing Texture2D images. Supports loading from resources, direct texture assignment, and async loading.
Constructor
new Image(texture2D); // Direct texture
new Image("path/to/texture"); // Load from Resources
new Image(asyncTextureTask); // Async loadingExamples
Unity Resource Loading
Load images from Unity's Resources system:
var ShowIcon = new ReactiveProperty<bool>(true);
// Load from Resources folder
new Image("Icons/download-icon")
.ClassName("action-icon");
// Conditional icon based on state
new Image()
.BindVisible(ShowIcon)
.ClassName("status-icon");Dynamic Image Selection
Switch images based on reactive properties:
var IsOnline = new ReactiveProperty<bool>(true);
// Icon that changes based on status
new Group(
new Image("Icons/online").BindVisible(IsOnline),
new Image("Icons/offline").BindVisible(IsOnline.Select(online => !online))
);UI Icons and Assets
Common Unity UI image patterns:
var Health = new ReactiveProperty<float>(1f);
var IsAdmin = new ReactiveProperty<bool>(false);
// Button with icon
new Button(
new Image("Icons/save"),
new Label("Save")
);
// Status indicator
new HorizontalGroup(
new Image("Icons/health").ClassName("health-icon"),
new ProgressBar(Health)
);
// Conditional visibility based on permissions
new Image("Icons/admin")
.BindVisible(IsAdmin);Properties
| Prop | Type | Default |
|---|---|---|
image | Texture2D | - |
disabled? | bool | false |
visible? | bool | true |
name? | string | "" |
pickingMode? | PickingMode | PickingMode.Position |
Methods
| Prop | Type | Default |
|---|---|---|
LoadImageAsync? | (Task<Texture2D>) => void | - |
Disabled? | (bool = true) => Image | - |
GetDisabled? | () => bool | - |
BindDisabled? | (Observable<bool>) => Image | - |
Visible? | (bool) => Image | - |
GetVisible? | () => bool | - |
BindVisible? | (Observable<bool>) => Image | - |
ClassName? | (string, bool = true) => Image | - |
BindClassName? | (string, Observable<bool>) => Image | - |
StyleSheet? | (StyleSheet) => Image or (string) => Image | - |
Image extends BaseElement.