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

Allow for editor-only nodes #56446

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Geometror
Copy link
Member

@Geometror Geometror commented Jan 2, 2022

This PR introduces an editor-only flag, providing a possible solution for godotengine/godot-proposals#3433. It can be used to mark nodes which should not be loaded added to the SceneTree when running the game or when the project is exported.

Although everything seems to work properly, I still would like to find a way to completely strip editor-only nodes from exported projects.

Animation1

Changes:

  • Add editor-only flag for all Node types (implemented with object metadata, so no overhead for normal nodes)
    Editor-only nodes are highlighted in the SceneTreeEditor. The flag can be set/removed with the toggle button in the menu band or removed with the button which appears directly in the SceneTreeEditor
    grafik

  • Added project setting to keep editor-only nodes when running the project.
    grafik

As always, feedback and testing is welcome :)

Bugsquad edit: This closes godotengine/godot-proposals#3433.

@Geometror
Copy link
Member Author

Rebased, made a few tweaks and removed the editor_only property from Light2D/Light3D/ReferenceRect since it becomes redundant with this PR.

@Calinou
Copy link
Member

Calinou commented Mar 30, 2022

Rebased, made a few tweaks and removed the editor_only property from Light2D/Light3D/ReferenceRect since it becomes redundant with this PR.

That reminds me, should we make Position2D/Position3D draw in projects by default? They can be made editor-only again with your PR now. Being able to see Position nodes in projects can be useful to diagnose various issues without having to add small cube MeshInstances.

@Zireael07
Copy link
Contributor

without having to add small cube MeshInstances

Welcome to my way of debugging AI paths xDDD Yes please to anything that will make it better

@KoBeWi
Copy link
Member

KoBeWi commented Apr 9, 2022

I did a small test based on this comment:

An option to completely remove the node at runtime would be nice. Sometimes we will want optional visibility, this can be easily accomplished with code, but sometimes it might be useful to ignore "editor-only" nodes completely and that's not totally feasible. We can remove the node only after it has been loaded and has taken resources up.

Apparently, when an editor-only node contains some resource, that resource will be loaded anyway. The reason is that you are stripping the node on load, but any resource referenced by that node is still in the scene and is being loaded. Any chance this could be fixed? It would be the best selling point for this feature.

@Geometror Geometror force-pushed the editor-only-nodes branch from f5b12f4 to 26d4295 Compare April 9, 2022 02:16
@Geometror
Copy link
Member Author

Rebased and changed the following:
Disallow setting the scene's root node editor-only. When the scene's root is contained in the list of selected nodes the "Editor only" toggle button is disabled.

@KoBeWi I will do some research on how this could be achieved, but I have a feeling that this might get quite complex because a resource can be shared by editor-only and "normal" nodes. This would require to check if a resource is unused before loading it, which may be tricky with the current metadata approach.

@fire-forge
Copy link
Contributor

It would be good to add the Editor Only toggle to the Scene tree node context menu. It could be a replacement for the toolbar button or they could both be kept; I'm not sure which would be better.

@reduz
Copy link
Member

reduz commented Jul 27, 2022

This is a really great feature, but it clashes with other similar stuff we have, and I am not sure the way its displayed is the best. I was thinking about renaming some editor_only flags we have in nodes like Light to edited_scene_only or something like this.

Might be worth doing some work on this after Beta so we can merge it properly.

@Calinou
Copy link
Member

Calinou commented Jul 16, 2023

I was thinking about renaming some editor_only flags we have in nodes like Light to edited_scene_only or something like this.

Might be worth doing some work on this after Beta so we can merge it properly.

What's the status on this, now that 4.0 is released? Also, only a handful of nodes currently have Editor Only properties. If we go forward with this PR or #77301, I'd suggest deprecating those properties (we have a system for that now).

@reduz
Copy link
Member

reduz commented Jan 4, 2024

I think this PR has a lot of value and it would be nice to revive it, I will try to write down proper feedback again ASAP so we can finalize it.

@geekley
Copy link

geekley commented Jan 10, 2024

Would this flag also allow runtime-only nodes? Because it would be useful to hide things only in editor too, without requiring code, and I think it could be through this same feature.

In fact, it would be best to already go one step further and do a more powerful and generic way to exclude nodes/resources anywhere. IMO the best implementation would be through a property availability of type PackedStringArray on Node and Resource. It would allow a list of platforms, i.e.:

  • every export platform (e.g. android, windows, ...) plus exported (meaning all of them) and its opposite editor
  • for export platforms, specific modes too, e.g.:
    android.x86_32, android.arm64.debug, windows.release, exported.release, ...
  • also editor.editing and editor.running for the specific modes of the editor platform

This property would have the special value ["everywhere"] by default.

In terms of UI, you could make the button toggle just the editor-only state by default, and show a more complete context menu with specific toggles if you right-click it or if it's any value except ["everywhere"] and ["editor.editing"].

@PLyczkowski
Copy link

I would go with a dropdown menu at the top of the inspector with Enabled/Disabled/Editor-only (RMB context menu is also fine but less discoverable), not adding a clickable icon, and signifying state in the scene tree view with graying out the name for disabled and coloring it for editor-only (I think yellow is taken, so maybe blue?)

@Geometror Geometror marked this pull request as draft May 30, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a property to make a node visible only in the editor or in the running project
10 participants