- Home /
Is it possible to set the size of EditorGUI.Foldout?
Hi guys, In the unity script reference EditorGUI.Foldout is shown to have a Rect parameter, both in the heading and in the example
EditorGUI.Foldout(Rect(3,3,position.width-6,15),showPosition, status);
I assume that something was changed in a recent version and the site hasn't caught up, as if I try the same thing I get the error
UnityEditor.EditorGUILayout.Foldout(bool, string,
UnityEngine.GUIStyle)' has some invalid arguments`
At the moment I'm using the code below to create a grid of enemy portraits which are contained in a foldout, but if I open it other elements clip through it. Is there any way around this?
showPosition = EditorGUILayout.Foldout(new Rect(0,0,0,0),showPosition, "Enemies");
if(showPosition){
foreach (Transform child in Selection.activeGameObject.transform){
if (child.name == "_Enemy Settings"){
var enemyList = child.GetComponent<_EnemyParty>();
for(int cnt = 0 ; cnt < 3 ; cnt++){
if (enemyList.inParty[cnt] != null){
if (GUI.Button(new Rect(50 * cnt, 20, 50, 50), enemyList.inParty[cnt].portrait)){
}
}
else{
if (GUI.Button(new Rect(50 * cnt, 20, 50, 50), "Empty")){
Debug.Log("Clicked the button with an image");
}
}
}
for(int cnt = 3 ; cnt < 6 ; cnt++){
if (enemyList.inParty[cnt] != null){
if (GUI.Button(new Rect(50 * (cnt - 3), 70, 50, 50), enemyList.inParty[cnt].portrait)){
Debug.Log("Clicked the button with an image");
}
}
else{
if (GUI.Button(new Rect(50 * (cnt - 3), 70, 50, 50), "Empty")){
Debug.Log("Clicked the button with an image");
}
}
}
for(int cnt = 6 ; cnt < 9 ; cnt++){
if (enemyList.inParty[cnt] != null){
if (GUI.Button(new Rect(50 * (cnt - 6), 120, 50, 50), enemyList.inParty[cnt].portrait)){
Debug.Log("Clicked the button with an image");
}
}
else{
if (GUI.Button(new Rect(50 * (cnt - 6), 120, 50, 50), "Empty")){
Debug.Log("Clicked the button with an image");
}
}
}
}
}
}
source = EditorGUILayout.ObjectField("My Label", source, typeof(GameObject), false) as GameObject;
Your answer
![](https://koobas.hobune.stream/wayback/20220613104025im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom Inspector Editor Foldout 0 Answers
How to get the LabelField that is under the mouse cursor? 1 Answer
EditorGUI.Foldout consumes click so GUI.Button doesnt work when inside of foldout region. 1 Answer
Property Drawer and Children 3 Answers
What's the equivalent of EditorGUIUtility.currentViewWidth for a foldout property? 1 Answer