Add "Inspect Native Shader Code" to shader inspector and shader editor
Implements and closes https://github.com/godotengine/godot-proposals/issues/10278.
Adds the action "Inspect Native Shader Code", currently available on the Material resource inspector (implementation), to the Shader resource inspector and to the shader editor.
I added the action to the shader editor under the File menu, because it's a valid action for both text and visual shaders. I can see reasons to instead do one of the following:
- Add the action to one of the other menus, like
Edit, which only appear for text shaders. This action is for advanced users, currently takes multiple seconds to open on my machine, and may be confused with the "Show Generated Shader Code" action in visual shaders. On the other hand, it is a valid action for both types of shader. - Not include this action in the shader editor at all. Perhaps it will cause more confusion than its worth. With this PR, you can now do
File -> Open File in Inspectorand thenManage object properties -> Inspect Native Shader Code.
Maybe hold off on merging. I want to see if being exposed to scripting causes problems, and if there's a good way to avoid exposing at least the new implementation to scripting. Un-exposing the Material implementation probably breaks compat even if it's correct to do.
Made the small style changes.
I also looked into whether the method needs to be exposed to the class DB and scripting, and I believe it does. The resource inspector dock uses the class DB to add methods to the Manage Object Properties menu. If we were only adding this method to the shader editor, there would be no need to expose it to scripting.
See the inspector dock implementation: https://github.com/godotengine/godot/blob/842f98239713fd10cfd648cd6aa3781895f289eb/editor/inspector_dock.cpp#L566-L583
@tetrapod00 I'm a little lost in the last few comments. Is this PR ready for merging now?
Yes, the PR is ready to merge.
The function Shader.inspect_native_shader_code() is exposed to scripting, which seemed unnecessary. I looked to see if there was a way to add this action to the Shader resource's inspector, without exposing it to scripting, but could not find one. The rest is all details.
Thanks!