Skip to content

format

typescript
Image.SetAtlasTexture(atlasUUID, textureUUID)

class: Image

description

The UUID of the atlas for this image object.

An atlas is assigned a globally unique identifier (UUID) to uniquely identify and reference them in code. This ensures that there are no duplicates or conflicts when using atlases in the game.

parameter

param_nametypedescription
atlasUUIDstringThe UUID of the atlas.
textureUUIDstring

reture

typedescription
void

code example

typescript
import { LunaEngine } from "LunaEngine";  
  
class NewScriptComponent extends LunaEngine.Component {  
    onStart(self: any) {  
        // Get the game object attached to this component  
        let gameObject = self.getGameObject();  

        // Get the UIComponent  
        let uiComponent = gameObject.GetComponent(UIComponent);  

        // Get the Image control  
        let image = uiComponent.FindChild(ControlType.Image, "Image");  

        // Set the atlas UUID for this image  
        let uuid = UUID128.new().ToString();  
        image.setAtlasTexture(uuid, "Assets/Textures/icon_Jump.png");  
        
        // Get the atlas UUID for this image  
        let atlasUUID = image.getAtlasUUID();  
        Debug.Log("Atlas UUID: ", atlasUUID);  
    }  
}