[GODOT 4.4.1]
Hi,
I try to understand how to load a pck file at runtime as a mod and instantiate a packedscene including a c# script.
From a blank project, I created a simple scene with a sprite2D and a script attach to it making it rotate. I export this as a PCK (or ZIP) file and load it in my current game.
I can instantiate this scene in my project (and the sprite2D is render) but it throw an error for loading the script attach to it :
Cannot instantiate C# script because the associated class could not be found. Script: 'res://Mods/Mods_Test/TestScene.cs'. Make sure the script exists and contains a class definition with a name that matches the filename of the script exactly (it's case-sensitive).
I have include the dll file (from .godot\mono\temp\bin\Debug
) in my game folder and load it using :
string mods_localized_path = "res://Mods";
string mods_globalized_path = ProjectSettings.GlobalizePath(mods_localized_path);
string absolute_path = System.IO.Path.Combine(mods_globalized_path, "Test.dll");
var assembly = Assembly.LoadFile(absolute_path);
No error is raised.
I have tried to get types from this assembly :
assembly.GetTypes()
.ToList()
.ForEach(t =>
{
GD.PrintS("Found type: ", t.FullName);
});
and get the error Could not load file or assembly 'GodotSharp, Version=4.4.1.0, Culture=neutral, PublicKeyToken=null'
I have absolutly no clue on how to handle that. If someone can give me a hint or something to try.
Update 21 - 04 - 2025:
I have tested with Assembly.LoadFrom(absolute_path);
. If I put the GodotSharp.dll
at the same place, I get no more error from getTypes call. The TestScene
class is present in the type list.
But the error still there when instantiate my nodeā¦