Article directory
Click to watchImage
1. Image panel
Click to access the image (Image)
● attributes
Attributes | Function |
---|---|
Source Image | A texture representing the image to display (must be imported as a sprite ) |
Color | the color to apply to the image |
Material | The material used to render the image |
Raycast Target | Enable Raycast Target if you want Unity to treat the image as a raycast target |
Preserve Aspect | Make sure the image keeps its existing size |
Set Native Size | Sets the dimensions of the image box to the texture's native pixel size |
2. RawImage panel
The difference from Image is the rendering texture (Texture).
Click to access the original image (Raw Image)
● attributes
Attributes | Function |
---|---|
Texture | A texture representing the image to display |
Color | the color to apply to the image |
Material | The material used to render the image |
Raycast Target | Enable Raycast Target if you want Unity to treat the image as a raycast target |
UV Rectangle | The offset and size of the image within the control's rectangle, expressed in normalized coordinates (range 0.0 to 1.0). The edges of the image will be stretched to fill the space around the UV rectangle |
Since the original image does not require a sprite texture, it can be used to display any texture available to the Unity player. For example, you can use the WWW class to display an image downloaded from a URL, or to display a texture from a game object.
The UV Rectangle property allows a small portion of a larger image to be displayed. The X and Y coordinates specify which part of the image is aligned with the lower left corner of the control. For example, an X coordinate of 0.25 would truncate the leftmost quarter of the image. The W and H (ie width and height) properties indicate the width and height of the portion of the image that is scaled to fit the control's rectangle. For example, a width and height of 0.5 will enlarge the image area by a quarter to fit the control rectangle. By changing these properties, the image can be scaled as desired (see also Scrollbar (Scrollbar) control).