The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

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

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

What am I doing wrong?

Godot version 3.4.2
in Engine by (13 points)

1 Answer

0 votes

This was super confusing for me too :)

Please read this thread: https://github.com/godotengine/godot-docs/issues/2148#issue-400639192

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
by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.