- Home /
 
new Line in a CustomPropertyDrawer
Hi, I'm currently making a customPropertyDrawer so a string[] will be look like an enum in the inspector and you can choose one.
I made a subclass for a entity / method pair:
     [System.Serializable]
     public class EntityMethodPair {
         public Entity target;
         public string method;
     }
 
               When I try to make a propertyDrawer for it, it will look like this: 
The code is:
 [CustomPropertyDrawer (typeof (EntityMethodPair))]
 public class EntityMethodDrawer : PropertyDrawer {
     
     Entity obj = null;
 
     public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {
         
         SerializedProperty target = prop.FindPropertyRelative ("target");
         SerializedProperty method = prop.FindPropertyRelative ("method");
         
         EditorGUI.BeginChangeCheck();        
         
         obj = (Entity)EditorGUI.ObjectField (pos, "target", obj, typeof(Entity));
                 
         // 2nd line
          Rect ExtraPosition = EditorGUI.IndentedRect(pos);
         ExtraPosition.y += 16;
         ExtraPosition.height = 16+5;        
     
         // draw popup list
         string[] methods = {"A", "B"};        
         EditorGUI.Popup(ExtraPosition,"method", 0, method);        
                 
     }
 }
 
               Now how can i get a 2nd line in there?
Answer by Bunny83 · Aug 08, 2013 at 10:53 PM
Have you read this page? If so, scroll down to the very bottom and you will find: GetPropertyHeight which is a method of PropertyDrawer which you can override to tell Unity the height of your property.
O$$anonymous$$ I've read that page but haven't seen that function, it works now thx!
Your answer
 
             Follow this Question
Related Questions
Limit on GUI Components? 0 Answers
Setting Scroll View Width GUILayout 1 Answer
How To Make Ammo & Realod for Gun & Spark for Gun ? 0 Answers
Floating Enemy Health Bars? 1 Answer
Trying to view paper object on button press GUI Texture 3 Answers