GradientField

Hi.

I have found that the GradientField method in EditorGUI and EditorGUILayout is private and is not available for public usage, It is really bad practice to disallow developers to use such useful API.

Anyway, I don’t know why this useful method is private and is not available for public, We hope to see this method be available for public.

There is another similar topic without answer: why EditorGUI.GradientField functions have internal access?

Also, there is an Feedback issue Make EditorGUI.GradientField() a Public API that was made about two years ago without any activity.

Thanks.

https://docs.unity3d.com/ScriptReference/Gradient.html

perhaps look like inspector can be used:
https://docs.unity3d.com/ScriptReference/EditorGUIUtility.LookLikeInspector.html

It’s a hack but you can https://docs.unity3d.com/ScriptReference/HideInInspector.html to disguise the elements that must be unseen.

… or maybe reflection.

The EditorGUIUtility.LookLikeInspector is not related and is obsolete though.
And the HideInInspector is used for MonoBehaviour/ScriptableObject fields not for EditorWindow or similar.

What I am looking for is to draw a field like ColorField or TextField for Gradients.
I know there is some workarounds for doing this manually without directly using Unity editor API, but Unity provided this API while not for Public, just for Private and Internal use, it is weird.
I have tried to use this method using Reflection and I was successful by doing this so, while the method could be provided as a public method.
And the Reflection has it’s faults, the first fault is the speed, the second fault is the complicated way of using it for just a simple task, …

Thanks.

I guess reflection is the only option sadly. There is no speed penalty here - it is an editor script…

But it is not drawn in Editor Windows, you need to access the API.

Gradient Editor for the custom inspector? HOW??? any luck?

I have read it before posting, nothing, they are using Workarounds, I am currently using Reflection, it is a workaround and it works, while the method should be provided for public use.

Feel free to add it to https://feedback.unity3d.com/

As far as I know it’s a really low priority and Unity does know about it, just they haven’t any priority assigned to it. Feedback helps them decide.

1 Like

Yes, nice, there is a feedback about it already https://feedback.unity3d.com/suggestions/make-editorgui-dot-gradientfield-a-public-api made about two years ago.

Thanks.