- Home /
 
               Question by 
               $$anonymous$$ · Mar 21, 2017 at 06:07 AM · 
                c#scripting problemassetdatabase  
              
 
              Excessive space in PropertyDrawer within Editor [ignore previous version of this question]
I'm creating an Editor for an array of items. I want a line for each item, with (a) the properties of the item and (b) some buttons to add, remove, and move the items. So I have created a PropertyDrawer for each item. That seems to be working, except it is leaving 3cm or so of space at the start of each line (if I do EditorGUI.PrefixLabel(), then it leaves the space after the "Element n'). Is there any way that I can get rid of the space?
Here are two fragments of my code.
 [CustomPropertyDrawer(typeof(Item))]
 public class ItemDrawer : PropertyDrawer {
 public override void OnGUI(Rect position,
                            SerializedProperty property,
                            GUIContent label) {
   EditorGUI.BeginProperty(position, label, property);
   int oldIndent = EditorGUI.indentLevel;
   EditorGUI.indentLevel = 0;
   using (var horizontalScope = new GUILayout.HorizontalScope("box")) {
     EditorGUILayout.PropertyField(
       property.FindPropertyRelative("firstproperty"),
       GUIContent.none,
       GUILayout.ExpandWidth(false));
     //more properties
   }
   EditorGUI.indentLevel = oldIndent;
   EditorGUI.EndProperty();
 }
 }
and
 [CustomEditor(typeof(TopLevel))]
 [CanEditMultipleObjects]
 public class TopLevelEditor : Editor {
 SerializedProperty items;
 
 void OnEnable() {
   items = serializedObject.FindProperty("items");
 }
 
 public override void OnInspectorGUI() {
   serializedObject.Update();
   EditorGUILayout.BeginVertical();
   int oldIndent = EditorGUI.indentLevel;
   EditorGUI.indentLevel = 0;
   for (int i = 0; i < items.arraySize; ++i) {
     EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
     EditorGUILayout.PropertyField(items.GetArrayElementAtIndex(i), GUILayout.ExpandWidth(false));
     using (var horizontalScope = new GUILayout.HorizontalScope("box")) {
     // create some buttons here
     }
     EditorGUILayout.EndHorizontal();
   }   
    EditorGUILayout.EndHorizontal();
   EditorGUILayout.EndVertical();
   EditorGUI.indentLevel = oldIndent;
   serializedObject.ApplyModifiedProperties();
 }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to create .asset file? 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Visual Studio Code Intellisense 0 Answers
Getting the Player in a Script! 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                