-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update exporting_pcks.rst #8486
base: master
Are you sure you want to change the base?
Conversation
Updating C# assembly loading instructions according to godotengine/godot#75352
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LookupScriptsInAssembly
method (as most everything else in the Godot.Bridge
namespace) is not meant to be used by users, if this API is exposed it's only because it's used by our source generators but otherwise it'd be internal API.
So I don't feel comfortable telling users to use this API. At least not without the proper explanation of what's happening.
Also, the plan was to make the type ScriptManagerBridge
internal and replace the LookupScriptsInAssembly
method with source generators (ScriptRegistrarGenerator
), so it'd be better if users didn't start relying on this API since we'll likely break compatibility here.
@@ -132,7 +132,7 @@ The PCK file contains a “mod_scene.tscn” test scene in its root. | |||
.. note:: | |||
For a C# project, you need to build the DLL and place it in the project directory first. | |||
Then, before loading the resource pack, you need to load its DLL as follows: | |||
``Assembly.LoadFile("mod.dll")`` | |||
``var context = AssemblyLoadContext.GetLoadContext(typeof(Godot.Bridge.ScriptManagerBridge).Assembly); var assembly = context.LoadFromAssemblyPath("mod.dll"); Godot.Bridge.ScriptManagerBridge.LookupScriptsInAssembly(assembly);`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work for multi-line code:
``var context = AssemblyLoadContext.GetLoadContext(typeof(Godot.Bridge.ScriptManagerBridge).Assembly); var assembly = context.LoadFromAssemblyPath("mod.dll"); Godot.Bridge.ScriptManagerBridge.LookupScriptsInAssembly(assembly);`` | |
.. code-block:: csharp | |
var context = Assembly.LoadContext.GetLoadContext(typeof(Godot.Bridge.ScriptManagerBridge).Assembly); | |
var assembly = context.LoadFromAssemblyPath("mod.dll"); | |
Godot.Bridge.ScriptManagerBridge.LookupScriptsInAssembly(assembly); |
@raulsntos That was a genuine concern of mine since there is a comment in the Somehow the Scripts in the imported dll need to be associated with the dictionary that tracks them. Maybe in that callback I mentioned? |
That's totally fair, thanks for the insight! Feel free to close this issue and notify other users on the original issue. If I understood it correctly, the assembly workflow will be reworked in a future version which should fix the issue? |
I hope it is prioritized that the original issue is resolved prior to making this breaking change, I intend on using this in the meantime and would like to not be completely blocked from keeping my engine up to date. |
What is the method now, to load scripts that are in runtime loadable assemblies, or to load scripts that are outside of the Godot project folder? |
Updating C# assembly loading instructions according to godotengine/godot#75352 (comment). Simply loading the assembly is no longer enough with godot 4 and @granitrocky identified how to load the dlls correctly.
Wasn't sure how to properly format the code inside the note block, so please suggest improvements, if necessary.