mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
Resource UID fixes and improvements
This commit is contained in:
@@ -2611,23 +2611,25 @@ Image::AlphaMode Image::detect_alpha() const {
|
||||
}
|
||||
|
||||
Error Image::load(const String &p_path) {
|
||||
String path = ResourceUID::ensure_path(p_path);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
|
||||
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path));
|
||||
if (path.begins_with("res://") && ResourceLoader::exists(path)) {
|
||||
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path));
|
||||
}
|
||||
#endif
|
||||
return ImageLoader::load_image(p_path, this);
|
||||
return ImageLoader::load_image(ResourceUID::ensure_path(p_path), this);
|
||||
}
|
||||
|
||||
Ref<Image> Image::load_from_file(const String &p_path) {
|
||||
String path = ResourceUID::ensure_path(p_path);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_path.begins_with("res://") && ResourceLoader::exists(p_path)) {
|
||||
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", p_path));
|
||||
if (path.begins_with("res://") && ResourceLoader::exists(path)) {
|
||||
WARN_PRINT(vformat("Loaded resource as image file, this will not work on export: '%s'. Instead, import the image file as an Image resource and load it normally as a resource.", path));
|
||||
}
|
||||
#endif
|
||||
Ref<Image> image;
|
||||
image.instantiate();
|
||||
Error err = ImageLoader::load_image(p_path, image);
|
||||
Error err = ImageLoader::load_image(path, image);
|
||||
if (err != OK) {
|
||||
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Failed to load image. Error %d", err));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user