Open poirierlouis opened 1 year ago
there's an addon that does (at least partially) that: https://godotengine.org/asset-library/asset/1252
there's an addon that does (at least partially) that: https://godotengine.org/asset-library/asset/1252
Thank you @mieldepoche, I didn't know about this one. This gave me a good head start in understanding the editor of the engine.
@Calinou, thank you for fixing the title. Also I'm currently implementing this proposal and I'm willing to make a PR once it is ready and accepted.
After asking about this proposal on Reddit, it reached around 410 likes with 26.2k views, where people brought to me known solutions, counter-arguments and new ideas. Many thanks to the community for these feedbacks.
I try to summarize the content of the thread below:
When
Color()
constructor is written, right-click onColor
, click onPick Color
to show a Color Picker, select new color, leave Color Picker to update and write the new color.
- This good solution, while hidden IMHO also lake the support of other formats. It is not shown in the PopupMenu when written with
Color.hex
and other static methods.- There is no preview.
- When updating the new color, it will force-use the Color constructor with the RGB float syntax
Color(r, g, b)
. This goes against the proposed idea to reuse the current format:Color("#ffa800")
could be changed toColor("#ff7b00")
instead ofColor(1, 0.48235294222832, 0)
.
@export
and uniform
:It is convenient to use the workflow of these keywords. It requires a scene file with a script / a material file with a shader, which is fine when one only want to configure the property in a specific node.
- This proposal target a different use-case which is developer oriented only. Currently, it is not as straight forward to preview / update a color code within the script and shader editors when it is not attached to a Node / a Material.
- This enhancement is specific to the default color value written in the file. Updating the exported value from a scene file is specific to the scene itself (and potential dependencies). But some dependencies might just use the default color value. Previewing and updating the default color right from within the editor is a gain of time.
IDE like VSCode provide a preview per color detected in a line.
- This solution seems to be the best, but it might need more work. Is this assumption (multiple color declarations per line) widely spread in usage to be worth the development?
- It might be the best world between current right-click solution along with a preview as a prefix to the color declaration.
Addon is Godot v4.0 compatible only. Addon (from README screenshot) do not cover all color formats declaration. As said, and seen in the Reddit post: it requires a user to know Godot support addons, to know such feature can exist, to search for it and install it (per project).
- Integrating this in the engine would benefit every users.
Integrating this in the engine could be backward-compatible to be cherry-picked in Godot v3.5.- Due to refactoring between v3 and v4, this will require specific work to be merged in v3.x.
Integrating this in the engine could be backward-compatible to be cherry-picked in Godot v3.5.
To clarify, new features can only be backported to 3.6, not 3.5.x. 3.5.x will only receive bug fixes.
To clarify, new features can only be backported to 3.6, not 3.5.x. 3.5.x will only receive bug fixes.
In deed, I guess I should have written 3.x
to match the branch name.
Anyway, as stated in the PR, and after taking a look at the 3.x branch, it won't be backwards compatible. This part of the code was refactored between v3 and v4.
To clarify, new features can only be backported to 3.6, not 3.5.x. 3.5.x will only receive bug fixes.
In deed, I guess I should have written
3.x
to match the branch name.Anyway, as stated in the PR, and after taking a look at the 3.x branch, it won't be backwards compatible. This part of the code was refactored between v3 and v4.
How is this coming along ? 🙂
How is this coming along ? 🙂
No idea, last time I was working on this PR I did not have further feedback. Now it needs merge conflicts to be fixed and validation process to start anew I guess. I'll wake up this PR as soon as I get my hand back on Godot.
Describe the project you are working on
Prototyping features with GDScript / Godot Editor before writing them with GDExtension to improve performance later.
Describe the problem or limitation you are having in your project
Currently, you need to get a color picker somewhere else in the engine (e.g. from a Material) or on the web when you need to update a color code in the editor. This slows the process of writing, updating or picking a color code. It is cumbersome to navigate to another part of the engine or another program to pick a new color and paste it back in Godot Editor.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
My proposal is to add a square aligned with a line of text when a color is detected. This square is filled with the detected color. The user can click on this square to open a dialog with the ColorPicker of Godot, change the value and validate the new color. The old color declaration in the line is then updated with the new value.
Square would be filled with a white background first, to reveal the alpha channel of the detected color (when used).
This is a feature you can find in IDE like IntelliJ. Such enhancement could improve engagement of the user within Godot Editor.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I've made an animated mock-up to show a possible solution of the enhancement I'm proposing:
An optional application of this enhancement within GDShader:
Use Cases
Color.hex
is updated toColor(r, g, b, a)
.Parse Color Rules
GDScript Accept color class declarations:
Color
constructorsColor.from_hsv
Color.from_ok_hsl
Color.from_rgbe9995
Color.from_string
Color.hex
Color.hex64
Color.html
Color8
methodColor
constantsGDShader
uniform vec4 my_color : source_color
declaration with a default value (required).Other text files It brings this feature in other text files, like Markdown.
0xRRGGBB[AA]
#RRGGBB[AA]
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, it is related to Godot Editor only.
It may be frequently used, declaration of
@export var COLOR := Color()
can be frequent when creating nodes. Such enhancement allows one to directly update the color code from the editor, which improve experience when user is a developer.Is there a reason why this should be core and not an add-on in the asset library?
It is related to Godot Editor, which is core.