- Home /
Find out default inspector height
Hi, i wonder if there is a way to calculate default inspector height? I am doing my own editor window where i am drawing my own smaller windows with GL. My problemy is that i want them to resize when content (default inspector of Scriptable Object) is expanded (like toggle list). Any ideas how can i achive that? Right now i am using scrollView but i really need them to resize. I wanted to get scrollView max height from its vector2 since i belive it is pixel size of hidden arena but i cannot find any acces to it.
Answer by hector_gutierrezc_tvj32015 · Jun 25, 2018 at 02:14 PM
you set the size of the inspector at the end, the best way is to every time you put a label or something like that you sum the line space it ocuped.
So you are saying that i need to count every line and multiply it by line height? So now my problem is how to count it... I mean, i just use editor.drawDefaultInspector of ScriptableObject (SO). It should be prepared for a lot of different SO. I belive i cannot get into it and find out if it has a list, and if that list is expanded, and if items in this list are also expanded. So how that GUI.Windows works? I need same behaviour, when list is expanded i need my window space to expand so it can be viewed without lost and without scroll.
//Normal List Draw
list.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) => {
var element = list.serializedProperty.GetArrayElementAtIndex(index);
//A for to make multiple labels of same things
for (int e = 0; e < lcn[index].sizeArray; e++)
{
//This set a Label for an scriptable object
Array[e] = (ScriptableObject)EditorGUI.ObjectField(new Rect(rect.x, rect.y + height, 120, EditorGUIUtility.singleLineHeight), Array[e], typeof(ScriptableObject), false);
a=Array[e] as YourTypeScriptableObject;
height += EditorGUIUtility.singleLineHeight + separation;
//Every loop iteration, it sum another line height to the general height of the inspector
}
//To change the height of every index on my list
heightArray[index]= height;
//Set the list of the gui to change it height, i pass index as a variable,
list.elementHeightCallback = (index) =>
{
Repaint();
//just paint the GUI
return heightArray[index];
};
}
Your answer
Follow this Question
Related Questions
Adjust the width/height of List property elements in the Inspector 1 Answer
Scroll view not resizing properly with dynamic content 0 Answers
Editor GUI Foldout header style customization 0 Answers
Custom Editor - Is there any way to detect whether the user is in Prefab editing mode? 1 Answer
UI Annoying bug 0 Answers