natiny.texture.update
natiny.texture.update(texture, resource)
Replaces the image inside an existing texture. The handle does not change.
Parameters
| Name | Type | Description |
|---|---|---|
texture |
number |
Live texture handle from natiny.texture.create |
resource |
number |
Resource handle containing encoded image data |
Example
local texture = natiny.texture.create(image_resource)
natiny.material.set_texture(material, "albedo", texture)
local replacement = natiny.resource.load("textures/winter.png")
-- later, with a different picture: the material is not touched again
natiny.texture.update(texture, replacement)
natiny.resource.destroy(replacement)
Notes
- Raises an error if the handle is not a live texture, or if the image cannot be decoded. A failure leaves the texture showing what it showed.
- Image data is copied during the call, so the resource may be destroyed after a successful update.