Loading Texture2D into EditorResourcePicker fails

Godot Version

4.3

Question

I am attempting to display a database record. One of its fields is a Texture2D and I have it set up an EditorResourcePicker Node with the baseType set to “Texture2D”.

When drag in a texture2d, it’s stored and serialized to the databases json.

The json data looks correct:

        "InventoryImage": {
          "LoadPath": "res://.godot/imported/texture_11.png-4a14768331028a1a342b1c7d79ebd736.ctex",
          "ResourceLocalToScene": false,
          "ResourcePath": "res://Assets/kenney_prototype_textures/orange/texture_11.png",
          "ResourceName": "",
          "ResourceSceneUniqueId": "",
          "NativeInstance": {
            "value": 16667478512
          }

However when I deserialize the json, I can verify that the resourcePath is valid on the value. I am trying to assign the Picker’s EditedResource by using ResourceLoader.Load to pass in the resource path.

However I get the error:

ERROR: Failed to set a resource of the type ‘Texture2D’ because this EditorResourcePicker only accepts ‘Texture2D’ and its derivatives.

When I try and use value.GetType and value.ResourcePath both return correct values from the json (which is where the actual file is). But it won’t let me load them and assign them. It works for packed scenes, for shaderMaterials. but not textures.

The workaround I found is to keep a backer friend I do serialize for the resource path, and have a Texture2D property I don’t serialize but has a getter to use resourceLoad.Load with the backer’s string path which is stored in the setter. It’s a janky workaround I don’t like, but more importantly I feel like it SHOULD work and am curious why it doesn’t.

Why does using ResourceLoader.Load in the getter work, but using it in the code dosn’t? And why am I getting such a strange rejection error?