Can I make a Foldout with TextField instead of a label?

Hi, I would like make a foldout with a textfield instead of a label, and of course, get the string from the textfield in foldout. Can I?

Nevermind, I already got it.


// Just use same Rect for both

Rect itemRect;

// First the TextField, then the Foldout.
// The reverse order whould leave the Foldout in front of TextField,
// and it can't be edited.
// Keep the TextField about 20 pixels to right, to not cover up the Foldout
yourString = EditorGUI.TextField(itemRect, yourString);

// Prepare for draw the Folout, more left than TextField
itemRect.x -= 20f;

yourBoolean = EditorGUI.Foldout(itemRect, yourBoolean, "", false);

This works for me. Thank you @Landern for the “motivation”…

Yes, yes you can, but it will be a custom control(or a composite of multiple controls) if you’re referring to creating it for Run time as opposed to using the editor ui fold out. So yeah, you can create it, go for it.