- Home /
What is the name of the GUIStyle that controls this GUIStyle enum effect?
https://gfycat.com/UnlinedGlitteringAldabratortoise - (Visual example of what Im talking about, I want to change the 3d effect to a flat color, to match the rest of the ui.)
I have a small custom editor that draws this ui, what is bugging me is I cant seem to find the guistyle to control the 3d effect on the enum. Ive changed normal,onnormal,active,onactive,focused,onfocused,hover,onhover but none of them seem to have an effect for this particular effect.
Sorry but it's not clear what you actually talk about. Which control do you mean? We can't tell what's an enum and what's just a button. Also you have to show your code of the relevant control. Each control usually has it's own style and some controls have several styles.
Sorry let me try again - Theres an enum dropdown box that I'm clicking on in the gif link. I want to change part of its visual effect.
By default unity renders buttons with a slight 3d effect.
Ive used GUIStyle.normal.background to change this default effect for buttons and enums (as well as active, hover, focus and their "on" equivalents)
I wasnt entirely successful though, there is still a default 3d effect that lingers after an enum has been clicked. When you click away from it, it returns to the custom look. How do I change this, what part of GUIStyle addresses this?
Answer by Bunny83 · Jun 21, 2018 at 10:02 AM
Ok so i guess you use the EditorGUI.EnumPopup control in your code? In this case it only uses the 4 none "on" states: "normal", "hover", "focused" and "active". Just have a look at the actual implementation of the underlying method. As you can see in line 2855 they pass false to the "on" parameter. The style state that you're looking for is most likely "focused" as this style is used when the drawn control has the keyboard focus. The focus is determined by GUIUtility.keyboardControl
and the passed controlID.
You may want to have a look at my IMGUI crash course, specifically at the GUIStyle section. Unfortunately since UnityAnswers messed up it's content renderer the post looks smashed together as paragraphs are now ignored and bulletpoint lists are no longer indented.
Fact is Unity doesn't render anything else for a GUIStyle. The GUIStyle is completely responsible for how it looks like on the screen. You said you set / replaced the focused state, but that's can't be true in your case. If you need / want any further help with this, again, post your code and how and where you create your GUIStyle. Keep in mind that creating a GUISin is usually the cleanest way to setup your own styles.
Your answer
Follow this Question
Related Questions
copy a GUIStyle into a new GUIStyle var using JavaScript 2 Answers
Remove Button Border 3 Answers
Variable from String 0 Answers
GUI works fine in editor, but not in build 2 Answers
GUI custom textfield cursor rendering 2 Answers