While coding the interface for another Editor extension I’m working on, I found myself wanting to nest a foldout label, inside of a toggle group, as opposed to having a regular label. There is a method for BeginToggleGroup that accepts a GUIContent as a label parameter, but the problem is, I’m not sure how to get a GUIContent object of the type I want since the standard method of making a Foldout:
foldoutValue = EditorGUILayout.Foldout(foldoutValue,"Foldout Label")
Leaves me with no references to the Foldout that I just created… Is there another way to make GUI stuff that lets me keep references?
In case anyone is interested I did find a reasonable work around:
EditorGUILayout.BeginHorizontal()
toggleVal = EditorGUILayout.BeginToggleGroup("",toggleVal)
foldoutVal = EditorGUILayout.Foldout(foldoutVal,"Foldout Label")
EditorGUILayout.EndHorizontal()
Creates the effect I wanted without truly ‘nesting’ the components (there are some alignment issues but a GUISkin could fix that). I’m still curious though if there’s any way to reference the objects made through these static functions.
Have you tried EditorStyles?
I never noticed that class before, since i used the EditorGUILayout functions for building the GUI I wouldn’t be surprised if EditorStyle skins were being used as the default, but I’ll definitely check it out. In fact I think one of my other editor extension windows relies on some regular UnityEngine GUI building functions and would probably look nicer if it used editor styles.