godotengine / godotengine/godot

TileSetAtlasSource.get_runtime_texture returns null

Open
#119,896 1 comment 0 reactions 0 assignees View on GitHub
documentation enhancement topic:2d
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.6.3.stable.official [7d41c59c4]

### System information

Godot v4.6.3.stable - Ubuntu 25.10 25.10 on Wayland - X11 display driver, Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Mesa Intel(R) Iris(R) Xe Graphics (ADL GT2) - 12th Gen Intel(R) Core(TM) i7-12700H (20 threads) - 14.86 GiB memory

### Issue description

```gdscript
var tileset: TileSet = load("res://default_tileset.tres") as TileSet
var src_id: int = tileset.get_source_id(0)
var atlas_src = tileset.get_source(src_id)
atlas_src.set_use_texture_padding(false)
var texture: Texture2D = atlas_src.get_runtime_texture()
```

The above works - but if you remove `set_use_texture_padding(false)`, or set it to `true`, then at the end of this block, texture is null.

Documentation for `get_runtime_texture` says

> If [use_texture_padding](https://docs.godotengine.org/en/stable/classes/class_tilesetatlassource.html#class-tilesetatlassource-property-use-texture-padding) is false, returns [texture](https://docs.godotengine.org/en/stable/classes/class_tilesetatlassource.html#class-tilesetatlassource-property-texture). Otherwise, returns an internal [ImageTexture](https://docs.godotengine.org/en/stable/classes/class_imagetexture.html#class-imagetexture) created that includes the padding.

Which sounds like the internal runtime texture is supposed to be created automatically (I'm not finding any way to create it explicitly)? Or possibly a non-dynamic resource texture should default to `use_texture_padding=false`? Or possibly the function should act like use_texture_padding is false when there is no padded texture?

### Steps to reproduce

In a fresh project with `default_tileset.tres` featuring just the Godot `icon.svg` icon,

```gdscript
var tileset: TileSet = load("res://default_tileset.tres") as TileSet
var src_id: int = tileset.get_source_id(0)
var atlas_src = tileset.get_source(src_id)
atlas_src.set_use_texture_padding(true) # this is just for clarity, since true is the default
var texture: Texture2D = atlas_src.get_runtime_texture()
print(texture)
```

- texture will be null, which I don't think is expected.

### Minimal reproduction project (MRP)

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.