-
-
Notifications
You must be signed in to change notification settings - Fork 10
assets.GetTexture
Jérôme Leclercq edited this page Dec 8, 2020
·
2 revisions
Retrieves an handle to a texture file, loading it if necessary. If the texture file cannot be loaded for some reason, this function returns nil.
assets.GetTexture([filepath: string]) -> texture: Texture | nil
-
filepath: Path to the image file (relative to the resources directory).
-
texture: Handle to the corresponding texture object ornilif the texture couldn't be loaded.
- If the texture is not already loaded, it will be loaded during this call (which may take some time).
-
This function will fail if the image file has not been registered server-side using RegisterClientAssets, independently from the file existence on the host filesystem.
- Only the following extensions are supported:
- bmp
- dds
- gif
- hdr
- jpg / jpeg
- pcx
- pic
- png
- ppm
- pgm
- psd
- tga
A simple script which loads a texture and print its size.
local texture = assets.GetTexture("texture.png")
if (texture) then
print("Texture size", texture:GetSize())
else
print("Texture couldn't be loaded")
end