Godot Version
v4.4.stable.mono.official [4c311cbee]
Question
I have an export variable that loads a dedicated “settings” resource for my class (a saved version of the resource with .tres extension)
// LOADS "DefaultTerrainEdgeSettings.tres" ; script is type TerrainEdgeSettings
[Export] public TerrainEdgeSettings EdgeSettings = (TerrainEdgeSettings)GD.Load<Resource>("uid://brdnr7varvh7p");
this spits out this error:
ERROR: ---> System.InvalidCastException: Unable to cast object of type 'Godot.Resource' to type 'TerrainEdgeSettings'.
however If I leave it unassigned, and use the inspector to assign the resource it works fine. Is this there something about the order things are loading that is breaking this? Is this a bug?
I wanna fix this, so I have the option to load resources inside scripts that aren’t attached to a node (like nesting resources inside resources)
EDIT:
Weirdly I can fix it by just loading it as a Resource and cast it whatever point in the script I need to read it / pass it ![]()