Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Demigiant · Feb 20, 2011 at 03:07 PM · editor-scriptingcustom-inspectorguistylefoldout

Custom inspector: changing foldout's text color

Hello,

I built a custom inspector, but I can't find a way to change the Foldout element text color.

I created a custom GUIStyle to use (foldoutStyle = new GUIStyle(EditorStyles.foldout)), and I'm trying to change its color via the usual foldoutStyle.[render state].textColor property. The thing is, nothing happens.

I tried all the possible render settings (foldoutStyle.normal, hover, active, onNormal, onHover, onActive, focused, onFocused), but to no avail. Or better, setting the focused.textColor property actually changes the text color, but only if the Foldout is closed. I can't find a way to change the Foldout color when it's open.

Any idea?

Thanks & a nice day :)

Daniele

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Feb 20, 2011 at 04:01 PM

Had the similar problem some weeks ago. I used EditorGUIUtility.LookLikeInspector()
and it works as expected. Even the function changes: Now you can click on the text to toggle. The control-style foldout ( EditorGUIUtility.LookLikeControls() ) only toggles when you click on the small arrow.

Don't know if there is a way to change the color of the control-style foldout... haven't found one yet.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Demigiant · Feb 20, 2011 at 04:22 PM 0
Share

Thanks a lot Bunny, this is very useful :) Though actually, I do need the LookLikeControls() look :/ I suppose this is a Unity bug then.

avatar image Demigiant · Feb 20, 2011 at 04:24 PM 0
Share

P.S. though I'll definitely try to switch to LookLikeInspector(): what you told me about the text activating the toggle is much nicer than having to click the arrow :)

avatar image Bunny83 · Feb 20, 2011 at 10:23 PM 0
Share

Sure ;) i just switch temporally and switch back right after drawing the foldout.

avatar image Demigiant · Feb 20, 2011 at 11:12 PM 0
Share

Oh, didn't realize it could be done (I thought it was kind of a global setting)! Thanks I'll definitely do it :)

avatar image Demigiant · Feb 24, 2011 at 05:47 PM 0
Share

Looks like there are no other solutions :P Checking yours as the "right hack" :)

avatar image
5

Answer by jite · Sep 27, 2012 at 06:00 AM

This works fine in any mode:

 GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);
 Color myStyleColor = Color.blue;
 myFoldoutStyle.fontStyle = FontStyle.Bold;
 myFoldoutStyle.normal.textColor = myStyleColor;
 myFoldoutStyle.onNormal.textColor = myStyleColor;
 myFoldoutStyle.hover.textColor = myStyleColor;
 myFoldoutStyle.onHover.textColor = myStyleColor;
 myFoldoutStyle.focused.textColor = myStyleColor;
 myFoldoutStyle.onFocused.textColor = myStyleColor;
 myFoldoutStyle.active.textColor = myStyleColor;
 myFoldoutStyle.onActive.textColor = myStyleColor;
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AntFitch · Jun 07, 2013 at 02:18 AM 0
Share

Thanks, this worked great!

avatar image
2

Answer by Demigiant · Feb 21, 2011 at 10:45 AM

Not really an answer, but some data based on Bunny83's hack (while waiting for an eventual non-hack solution - if it exists :P).

The unstylable Foldout issue happens if you're using the EditorGUIUtility.LookLikeControls() mode

Otherwise, it's still a mess! Applying EditorGUIUtility.LookLikeInspector() just before the Foldout creation (and reverting to LookLikeControls() immediately after) allows to style the Foldout, though not that easily. Here is a list of render settings for each Foldout state (the unlisted ones have no use):

  • normal: Foldout closed and unfocused
  • active: on Foldout click when closed
  • onNormal: Foldout open and unfocused
  • onActive: on Foldout click when open
  • onFocused: Foldout open and focused (attention here: needs onActive and focused to be set/changed, otherwise it doesn't work!)
  • focused: Foldout closed and focused

I tested this not by creating an entirely new GUIStyle, but by cloning the default with foldoutStyle = new GUIStyle(EditorStyles.foldout)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to achieve proper inspector functionality (blue highlight of last tweaked) with elements from the GUI class (not from EditorGUI) 1 Answer

Inspector foldout with inheritance 0 Answers

Persistently changing variables from custom editor 2 Answers

Showing member ScriptableObject's in the Inspector 5 Answers

"User is Dragging the Transform Gizmo" in Editor 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges