godot icon indicating copy to clipboard operation
godot copied to clipboard

Implement tooltips for shader uniform in the inspector.

Open magian1127 opened this issue 3 months ago • 3 comments

Initially, the implementation was done by modifying shader_language.cpp,look at. https://github.com/magian1127/godot/commit/49fe127a0a3d92a73af6a387d63a4a0a71c30a8a However, some issues were discovered, so it was decided to switch to using regular expressions and modify shader.cpp to achieve the desired outcome. Using /** */ on top of uniform will do the trick.

/**tip
tip2*/
uniform float test1= 2.0;

image

一开始是修改 shader_language.cpp 来实现的, 代码看这里. https://github.com/magian1127/godot/commit/49fe127a0a3d92a73af6a387d63a4a0a71c30a8a 但是发现有些问题, 还是改用正则表达式, 以及修改 shader.cpp 来实现. 在 uniform 上面使用 /** */ 就可以实现.

  • Production edit: This closes https://github.com/godotengine/godot-proposals/issues/7846.

magian1127 avatar Apr 03 '24 06:04 magian1127

Thanks for opening a pull request :slightly_smiling_face:

Note that the proposal had a different syntax in mind, as opposed to using multi-line comments directly:

/// Like this (notice the 3 slashes, not just 2).
/// Example continuation line.
uniform int something = 2;

The reason we don't want to use standard multi-line comments is that you should be able to have a regular (non-doc) multiline comment above a uniform, and have it not be picked up by the editor inspector for public display.

This multiline docblock syntax could also be supported, but it's much more verbose especially when written within a shader. I probably wouldn't bother for now, but I'll leave it here for posterity:

/**
 * Like this (notice the two asterisks above).
 * Example continuation line.
 */
uniform int something = 2;

Calinou avatar Apr 04 '24 21:04 Calinou

It has now been changed to /** for matching. Other methods would make multi-line comments, code, and regex become more complicated.

magian1127 avatar Apr 05 '24 07:04 magian1127

done

magian1127 avatar Apr 23 '24 09:04 magian1127

Thanks!

akien-mga avatar Apr 29 '24 08:04 akien-mga