Hello,
Ive just grabbed an example from the web and playing with it to learn about Property Drawer.
Just wondering if someone could inform me why I get a little side scroll on int arrays when I place it under an existing array. If you look at the image you can see the difference between the two. How can I kill it !!
[CustomPropertyDrawer(typeof(GridData), true)]
public class GridDataPropertyDrawer : PropertyDrawer {
public override void OnGUI(Rect position,SerializedProperty property,GUIContent label){
EditorGUI.PrefixLabel(position,label);
Rect newposition = position;
newposition.y += EditorGUIUtility.singleLineHeight;
SerializedProperty data = property.FindPropertyRelative("rows");
//data.rows[0][]
for(int j=0;j<GridData.numRows;j++){
SerializedProperty row = data.GetArrayElementAtIndex(j).FindPropertyRelative("colum");
newposition.height = EditorGUIUtility.singleLineHeight;
if(row.arraySize != GridData.numColums)
row.arraySize = GridData.numColums;
newposition.width = position.width/GridData.numColums ;
for(int i=0;i<GridData.numColums;i++){
EditorGUI.PropertyField(newposition,row.GetArrayElementAtIndex(i),GUIContent.none);
newposition.x += newposition.width;
}
newposition.x = position.x;
newposition.y += EditorGUIUtility.singleLineHeight;
}
}
public override float GetPropertyHeight(SerializedProperty property,GUIContent label){
return EditorGUIUtility.singleLineHeight * GridData.numRows + EditorGUIUtility.singleLineHeight;
}
}