Skip to content
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

Camera2D in a viewport while running as an editor plugin doesn't work #33931

Closed
Nukiloco opened this issue Nov 27, 2019 · 7 comments · Fixed by #79867
Closed

Camera2D in a viewport while running as an editor plugin doesn't work #33931

Nukiloco opened this issue Nov 27, 2019 · 7 comments · Fixed by #79867

Comments

@Nukiloco
Copy link

Nukiloco commented Nov 27, 2019

Godot version:
Godot v3.1.2

OS/device including version:
Windows 10

Issue description:
Whenever running as an editor plugin, Camera2D nodes won't work in a separate viewport.

Steps to reproduce:

  1. Make an EditorPlugin.
  2. Make a scene with a Viewport, Sprite and a Camera2D node.
  3. Add a script to make the Camera2D node move around.
  4. Run the editor plugin and try to move the camera around.
  5. The Camera2D node doesn't work at all.

Minimal reproduction project:
https://github.com/Flairieve/GraphicsEditor/

@novemberist
Copy link

novemberist commented Nov 27, 2019

I don't think your Camera2D script will actually run in the editor, unless you make it a tool, too. At least if I understand this article correctly: https://docs.godotengine.org/en/3.1/tutorials/misc/running_code_in_the_editor.html

If you add the tool keyword, the camera actually moves within your viewport in the editor. However, in that case the Viewport doesn't scroll with it (probably because it is not the active camera in the editor viewport). I think this might be an issue with your implementation, rather than a bug. Wouldn't know how to fix this, though.

@Nukiloco
Copy link
Author

The camera script isn't a tool script on purpose so it doesn't run in the editor scene. I have tried it before as a tool script and that didn't work also. I think it's something that has to do with using viewports in the editor.

@bojidar-bg
Copy link
Contributor

You might have to use a custom script which modifies the viewport's "canvas_transform", as Camera2D is specifically made to not run while Engine.editor_hint is true.

@Nukiloco
Copy link
Author

Nukiloco commented Nov 28, 2019

If that's the case then shouldn't camera nodes be allowed to run in the editor if they are under a viewport? I feel like it's more tedious to remake the entire camera script just to move around in a viewport in the editor.

@bojidar-bg
Copy link
Contributor

The thing in the middle of the editor screen is already a viewport, so this would require some changes to how viewports work.

@Nukiloco
Copy link
Author

Wait so the editor can only run a couple of viewports at a time?

@Nukiloco
Copy link
Author

Even with that, you should be able to use a viewport with a camera in it as an editor plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants