-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Fix Camera2D is not working inside a MainScreenEditorPlugin #79867
Conversation
WhalesState
commented
Jul 25, 2023
•
edited by Calinou
Loading
edited by Calinou
- Production edit: This closes Camera2D in a viewport while running as an editor plugin doesn't work #33931.
just one more fix, draw screen/limits/drag margins are not updating if is editing in editor and inside a custom viewport, how to fix it ? by checking |
I think removing _is_editing_in_editor() checks inside the 3 methods will fix it since it only calls queue_redraw() which will draw them in the next process frame, testing now and i hope it works as expected. edit: still not updating -_- |
After testing I have found that this has many benefits: 1- Camera2D works as expected in Editor edited scene root if not inside a SubViewport else it will directly update the SubViewport preview from the camera if it's enabled , and if disabled it will has no effect but only draw screen/limits/drag_margins will not be shown if anyone can help me making draw screen/limits/drag margins be visible if inside a SubViewport and not enabled, note that you need to draw to the Subviewport and not the root viewport. |
The approach overall makes sense, though I haven't reviewed or tested the changes yet. One thing that you'll have to do eventually for this to be merged is to squash your commits into one. Please, make sure that the final commit has a short but descriptive message (the title of this PR is a good option). See this documentation, if you need help with squashing. |
i want to cry, i have done this |
Also I'm sorry about the refactor, just have got many warnings from CodeScene plugin about complex expressions. also the last edit makes the Camera works only inside a MainScreenEditorPlugin and no changes happens to it inside edited scene root, this is amazing and also it's not updating anymore! thank you ^^ |
should i change |
It is an editor build only method, you can only use it in editor only code, it's not a direct replacement |
can i make a function like this and use it instead ? bool _is_editing_in_editor() const {
#ifdef TOOLS_ENABLED
return is_part_of_edited_scene();
#endif
return false;
}
|
Sure, though it should be; bool Camera2D::_is_editing_in_editor() const {
#ifdef TOOLS_ENABLED
return is_part_of_edited_scene();
#else
return false;
#endif // TOOLS_ENABLED
} Or you'll get errors by returning multiple times Though I'm not sure about the exact best solution here, it feels pretty hacky Edit: You can't use a local function like that, it has to be a member function to access a member method Unless you do: static bool _is_editing_in_editor(const Camera2D *p_camera) {
#ifdef TOOLS_ENABLED
return p_camera->is_part_of_edited_scene();
#else
return false;
#endif // TOOLS_ENABLED
} And provide it with |
one more const function isn't a big deal for this fix, right ? bool Camera2D::_is_editing_in_editor() const {
#ifndef TOOLS_ENABLED
return false;
#else
return is_part_of_edited_scene();
#endif // !TOOLS_ENABLED
}
|
using |
If you have "if - else", then there is no reason to use |
There is a bug, the camera borders no longer follow the node: godot.windows.editor.dev.x86_64_0gCNP1oYgA.mp4 |
fixed, I could never have done this without your help. Thank you all and lets meet in another issue and we fix it together, I'm excited to learn more from you. ^^ Note: the editor may appear slow because it's built with 09.08.2023_07.09.55_REC.mp4 |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Thank you, I'm so happy ^^. have a nice day 🎉. |