StreamTexture in Godot 4: Could not find type "StreamTexture"
By Eduardo Orellana · Updated
StreamTexture is called CompressedTexture2D in Godot 4. A Godot 3 script that types a variable as StreamTexture fails to parse with Could not find type "StreamTexture" in the current scope; type it as CompressedTexture2D, or as Texture2D if any 2D texture will do.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
When GDScript loads a script it resolves every type annotation. StreamTexture is not a class in Godot 4, so the analyzer stops with Could not find type and none of the script runs.
Godot 4 renamed the texture an imported image loads as. Its 3-to-4 converter carries StreamTexture and StreamTexture2D to CompressedTexture2D, StreamTexture2DArray to CompressedTexture2DArray, and StreamTextureLayered to CompressedTextureLayered.
The class reference describes CompressedTexture2D as a texture loaded from a .ctex file, a format internal to Godot that the import system creates from other image formats. It inherits Texture2D, which the fix printed.
Reproduce it
A Godot 3 script that types a texture as StreamTexture, in a Godot 4 project. The scene is one Node with this script.
extends Node
var icon: StreamTexture
func _ready():
print(icon)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Could not find type "StreamTexture" in the current scope.
at: GDScript::reload (res://answers/streamtexture-in-godot-4/repro.gd:3)
ERROR: Failed to load script "res://answers/streamtexture-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
Type it as CompressedTexture2D. A texture loaded from an imported image is one, and it is a Texture2D, so a variable typed Texture2D also takes it.
extends Node
var icon: CompressedTexture2D = CompressedTexture2D.new()
func _ready() -> void:
print(icon.get_class(), " is Texture2D: ", icon is Texture2D)
print("parent class: ", ClassDB.get_parent_class("CompressedTexture2D"))
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
CompressedTexture2D is Texture2D: true
parent class: Texture2DVerified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 6 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: [gdscript_analyzer.cpp line 904, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L904), [renames_map_3_to_4.cpp lines 1607 to 1610, StreamTexture to CompressedTexture2D](https://github.com/godotengine/godot/blob/4.7.2-stable/editor/project_upgrade/renames_map_3_to_4.cpp#L1607), [CompressedTexture2D class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/CompressedTexture2D.xml).
Questions
- What about StreamTexture2D, StreamTextureLayered and StreamTexture2DArray?
- They took the same rename: StreamTexture2D is CompressedTexture2D, StreamTexture2DArray is CompressedTexture2DArray, and StreamTextureLayered is CompressedTextureLayered.
- Should I type the variable as CompressedTexture2D or Texture2D?
- CompressedTexture2D inherits Texture2D. Type it Texture2D when the variable may also hold a texture made in code, such as an ImageTexture; CompressedTexture2D only fits a texture loaded from an imported file.
Related
- Spatial in Godot 4: it is Node3D now, and translation is position
- KinematicBody2D in Godot 4: it is CharacterBody2D now
- Every verified Godot 4 answer
- StreamCubemapArray in Godot 4: Identifier not declared in the current scope
- ToolButton in Godot 4: use a flat Button
- Cannot infer the type of "…" variable because the value is "null" in Godot 4
- Sprite in Godot 4: it is Sprite2D now
- The "tool" keyword was removed in Godot 4: use @tool
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free