-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting "Loaded resource as image file" warning, but the code is legit because it runs in editor #24222
Comments
I'm also having this problem, and I have no idea what kind of code I'm supposed to use to fix it. How do I import as an Image resource and then load it as a resource? I save & load images via code. |
@aaronfranke you can change the import setting like this: In my case this warning is useless because I can't ask the user to change import settings on images just because my plugin loads them for editor purposes. |
I, too, ran into this problem. When writing C# code, I can't figure out how to invoke
I would really appreciate a work-around or solution. |
@nightblade9 a work around would be: var sprite = new Sprite();
sprite.texture = load("res://assets/images/foo/bar.png") Make sure that in the import settings (By default on the left next to the scene tab) you select import as Texture. |
I should prob not ask this here but, I have re-imported my icon.png to a texture resource but it still trows this error at me when trying to export/debug HTML5 any ideas on what I could be doing wrong? |
@Tarudahat have you tryed ro script it instead of going through the editor. |
@balgu No I havn't how would I do that? |
This is probably the icon.png problem:
Given that the error message is basically cryptic, I suggest the error message change slightly if the offending icon a res://... in the project's Application/Config settings. |
@merriam Where did you see that |
I've found a workaround to this in #39396 (comment). 🙂 static func image_load_no_warning(filepath):
var image = Image.new()
image.load(ProjectSettings.globalize_path(filepath))
return image |
TL;DR: Error also comes from Export when the application icon is PNG on macOS. Let me a bit more clear about behavior on macOS: This should work: So, then this should work: This should not work, but it does: This should work, and it does: In my humble opinion,
|
We can't specify how stack traces are presented for specific error messages. |
True. Still, the "Instead, import the image file as an Image resource..." is incorrect here. Might be better to point to web page explaining in depth the reasoning and work around? There isn't a one size fits all advice, and it does seem odd restriction. |
#42412 adds a link to the Importing images page in the documentation, as well as the current warning and a possible solution, depending on your use case. 🙂 |
As I said, importing as an image is not an option in my use case. My case fits your doc requirement: In fact, despite this issue is about the editor use case, I realized it may not even be the only one: at least one of my images needs to be loaded BOTH as an image and a texture, the heightmap, because of physics. Users sometimes also need to access terrain maps from scripts. Importing only allows one type, and as far as I understand |
Github doesnt allow me to edit today so I'll amend with an extra message: |
Yes, there are #39396 and #42653 by now which can either mitigate the warning or remove it completely, because I don't see a way to make the warning condition specific to those described use cases. And images/textures are not the only type of resource which can have the same import/load problem in exported projects, it just happens to be most frequently used type of resource, I believe that's just a kind of "limitation" (feature!) which one has to be aware of, so that's why I'm suggesting documentation changes as well. |
Meh. I'm bowing out of the discussion. At this point, I truly do not understand why the limitation exists, why it is not automatically mitigated, nor why there there is not clear documentation explaining why it must exist. I guess it's a Godot Thing like GIMP refusing to have a circle tool. |
@merriam there's no limitation with this specifically, it's just currently an annoyance. 😄 The limitation I mentioned is with the import/load dilemma which is inherent to Godot's design at large, as described in godotengine/godot-proposals#1632. The problem this warning is trying to prevent is exactly usages like #24222 (comment) (loading images like this would make it fail to load textures once the project is exported, because original images are not part of The discussion is almost the opposite to what Akien said to me in #31832 (comment):
I totally understand now that if a error/warning message doesn't apply to most use cases, then the possible rationale should not be printed. Documentation is here: #42412. Alternatively, perhaps adding Another alternative is to move the image.load("res://icon.png".globalize_path()) But then again, the issue as described in #24222 (comment) cannot be even worked around via script. |
I haven't followed all recent discussions and proposals around this, but to clarify: the warning raised by IMO adding this warning was not particularly a good solution and a more thorough rethinking of the UX around importing assets and loading them at runtime needs to be done. |
Just a note to say it still happens in Godot 3.4.4 (and likely in 4.0 though I havent tested). It is even printed while doing nothing upon project opening, due to the preview thumbnail generator loading images for the first time. |
I can't workaround this issue in Godot 4.0 with this suggestion. |
Also developing a plugin. v4.2.beta4.official [93cdacb]. This emits that warning: I can't know iconpaf before hand, it's an editor plugin. BTW icon_paf is stuff like: "res://addons/dabber/assets/icons/dabList.small.svg" Warning text:
|
You may be able to work this around using: The warning is only printed if the parameter passed to |
I hacked a bit and tried: And, Lo, silence with a nice icon! The docs do mention it, but I find the whole Image / Texture thing very confusing and always read their docs with a kind of panic. |
Godot 3.1 alpha2
In my terrain plugin, I deal with images often and also save and load them with
Image.load()
andImage.save_png()
using the project resource paths. The reason I'm doing this is because I want them to be editable in the editor, and textures areImageTextures
, while they will beStreamTextures
in the exported game (in which case I useload
normally, unless the game itself also wants to edit them).On a side note, it forces me to swap between
StreamTexture
andImageTexture
quite often, honestly I don't really get the difference between them as an API.But the point is, it makes the editor throw these warnings often:
I don't know how I am supposed to avoid it. My plugin has to load images, forcing them to have an import option to load them as images is not fit to the task here.
The text was updated successfully, but these errors were encountered: