C# - No loader found for resource

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KinguKurimuzon

I’m trying to load a scene PlayerBattler which inherits from another scene called BattlerBase, which in itself inherits from KinematicBody2D. However, when I attempt to load PlayerBattler with ResourceLoader, I get an error saying “No loader found for resource: res://path”, and it fails to load. Loading BattlerBase works fine, so I assume this has something to do with PlayerBattler’s inheritance. Does anyone know why this is happening, and is there some kind of workaround for this?

res://path is not a valid resource path. Are you sure you are trying to load your resource using a valid path? Can you show the code where you do this?

Zylann | 2018-02-27 13:51

Yes, I’m using a valid path. That was just there as an example. The code looks like this, but the path is stored in a string in an autoload:

PackedScene NewBattler = ResourceLoader.Load(PartyMember.BattlerPath) as PackedScene;
BattlerBase NewBattlerConvert = NewBattler.Instance() as BattlerBase;
BattlerList.Add(NewBattlerConvert);
PlayerParty.Add(NewBattlerConvert);

BattlerPath = "res://Scenes/Entities/Battle/Party/PlayerBattler.tcsn";

KinguKurimuzon | 2018-02-27 19:06

Which path do you get if you print PartyMember.BattlerPath? How is that variable initialized?

Zylann | 2018-02-27 19:59

I probably could’ve explained this a little better. The first four lines there are from BattleWorld.cs, and the string with the path is from another script. I’ve already checked and yes, that first line is loading res://Scenes/Entities/Battle/Party/PlayerBattler.tcsn. It’s a bit of a lengthy process, I have an autoload called PlayerManager with a List called Party. Party currently holds another autoload holding the stats of one specific party member, and that there holds the BattlerPath string. PartyMember.BattlerPath is based on this foreach:

foreach (BaseStats PartyMember in PlayerManager.Party)

There’s probably a more efficient way to do all this, but that’s not my concern right now.

KinguKurimuzon | 2018-02-27 20:55

At this point I (or devs) would need a minimal reproduction project to see where the issue is.

Zylann | 2018-02-27 21:19

I just tried to reproduce it in a new project, but it ended up working like it’s supposed to, so I’m not entirely sure what to say. Clearly this’ll take a little more looking into.

KinguKurimuzon | 2018-02-27 22:28

:bust_in_silhouette: Reply From: KinguKurimuzon

Okay, so the main project is just working like it should now. I couldn’t possibly tell you why it’s working, all I did was put the path directly into ResourceLoader.Load() then swap it back out for PartyMember.BattlerPath, but it’s working now.