-
-
Notifications
You must be signed in to change notification settings - Fork 23.6k
Allow editor plugins to modify run arguments #107671
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
Conversation
cc21f5f to
65d28c4
Compare
|
This could still use more testing, although, it's working well for me on Linux (both with the embedded game view and not) so I think I'll take it out of draft NOTE: this is squarely targeting Godot 4.6 at this point |
|
I think it would be more efficient if you just passed the Vector as argument and don't expect it to be returned. Since it's passed as reference, the plugin can modify it all the same, without making an unnecessary copy. Although the copy is only made when a plugin implements the method, so it's probably fine either way. I also noticed that there is discrepancy between arguments passed to the new method and the ones returned by |
|
What are the debugger changes for? |
|
@KoBeWi Thanks for the review!
While passing it as a reference and modifying it in place would work in the engine itself, I don't think it would work from GDScript or GDExtension. In that case, I think a copy would be made as soon as any elements were removed or added to the Since this only happens when the user clicks the "Run project" or "Run scene" button, I don't think we have to worry about being very efficient here.
This is by design. I don't think we want plugins to mess with all the arguments that the editor adds automatically, just the additional ones. Otherwise a plugin could sneakily change which scene is being run, or the port the debugger is going to connect to, etc.
To allow the application to trigger itself to relaunch with different arguments, while still allowing the new instance to run in the embedded game view (if enabled) and connect to the debugger. These changes are to enable PR GodotVR/godot_openxr_vendors#312 for the godot_openxr_vendors GDExtension. That PR aims to allow basically the same as PR #103972 (which only works when running the editor on Android), but instead simulating it on the desktop, so you can test hybrid apps (XR apps that can switch between immersive and 2D panel modes) without having run on a real headset. |
How can this be tested? |
Well, you can test it via GodotVR/godot_openxr_vendors#312 and the Meta XR Simulator, but that's a lot of extra stuff to setup :-) So, here's a minimal demo app to test it: |
|
Here's a scene that does (almost) the same in vanilla Godot: I guess adding |
I tried a whole bunch of times, but could not get this to work for me on Linux (X11). I also suspect that it would cause problems with the embedded game view even on platforms where it's working, but I haven't tested that
Sure, I can move it to its own PR!
UPDATE: Actually, I don't need both, only this one! See this comment for the details |
65d28c4 to
15fc3cf
Compare
15fc3cf to
da1256d
Compare
I tested this and indeed GDScript makes a copy.
Being inefficient may affect project starting time. It's likely not a problem here, but optimizing it won't make the code much more complex. Though it only involves internal changes, so it can be done in a follow-up PR if you don't want to do it now. |
Calinou
left a comment
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.
Tested locally, it works as expected. Code looks good to me.
Testing project: test_pr_107671.zip
This project contains an editor plugin that implements "play from position" functionality.
play_from_position.mp4
Note that one limitation with this approach is that arguments are always appended at the end, with no way to control the order between plugins. This can have an importance if you're passing user command line arguments (i.e. --engine-arg -- --user-arg), as anything after -- will be ignored by the engine itself and treated as an user argument.
Having support for specifying user command line arguments in a way that isn't reliant on order (e.g. +user-arg) could help resolve this in the long run.
da1256d to
ffb315c
Compare
|
@KoBeWi: Thanks for all the review!
I still really don't think this will be inefficient: Anyway, I've gone ahead and modified the code as you described here:
We actually don't need
Thanks for the testing and review! That's a really cool use for this feature :-) |
c356373 to
c4b7943
Compare
c4b7943 to
d548586
Compare
Not really. You get access to the whole argument array, so you can check if another plugin has already added |
d548586 to
15dace3
Compare
15dace3 to
3d46656
Compare
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.
I kind of get why, and maybe it has been discussed in the past, but why does this function have to return a new array derived from the original, instead of modifying the array in-place (which would probably require an Array[String], or potentially having the returned value appended onto the original array internally?
I just personally find the approach of "take the array as a parameter, then return almost the same array, if you want" to be awkward API.
While modifying the array in place works in C++ within the engine itself, in either GDScript or GDExtension, modifying the array in-place won't update the original because of copy-on-write. I'm not sure what you mean by "having the returned value appended onto the original array internally"? |
3d46656 to
fe27a72
Compare
Essentially the same behavior as Object's |
Unfortunately, if this is limited to only adding arguments, then it won't work for the use case I created this PR for - I need to be able to remove and modify arguments as well. |
|
Thanks! |
This PR aims to allow editor plugins to control the arguments that are used when launching a project from the editor
The ultimate goal is to allow the godot_openxr_vendor extension to simulate running a hybrid immersive/flat VR app on desktop, so you don't need to deploy to the headset for testing.
See GodotVR/godot_openxr_vendors#312 for the rest of the implementation of that (also depends on #108852)
This is a DRAFT for now, because I need to do more testing (especially with the new embedded game view on multiple platforms)