Topic was automatically imported from the old Question2Answer platform.
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");
pack.Flush(true);
ProjectSettings.LoadResourcePack("dlc.pck");
var sprite = new Sprite();
sprite.Texture = (Texture)ResourceLoader.Load("res://qwop.png");
AddChild(sprite);
Problem is when I load the “qwop.png” texture to a sprite I get this error
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 = Image.new()
var texture = ImageTexture.new()
image.load('res://qwop.png')
texture.create_from_image(image)
sprite.texture = texture