Cannot load texture from pck file created using PCKPacker

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Delin

I’m making a pck file and putting the default icon.png in it this way

var pack = new PCKPacker();
pack.PckStart("dlc.pck", 4);
pack.AddFile("res://qwop.png", "icon.png");
var sprite = new Sprite();
sprite.Texture = (Texture)ResourceLoader.Load("res://qwop.png");

Problem is when I load the “qwop.png” texture to a sprite I get this error

_load: Resource file not found: res://qwop.png.
load: Error loading resource: 'res://qwop.png'.

What am I doing wrong?

:bust_in_silhouette: Reply From: SylvanSign

This was super confusing for me too :slight_smile:

Please read this thread: Clarify what an imported resource really is and how to load external files (png, jpg, ogg, wav...) · Issue #2148 · godotengine/godot-docs · GitHub

The TL;DR is that you need to treat “imported” and “not imported” files as separate things.

So the code you have looks fine until you call ResourceLoader.Load on the packed png and expect to get a Texture back. Instead, you would have to do the C# equivalent of this

var image =
var texture =
sprite.texture = texture