- Home /
Question by
afra-frantic · Dec 02, 2016 at 06:20 PM ·
unityeditorserializationdrawer
Show rows Variables in a few lines, for each element with using unityEditor
Hi i create a custom property drawer. like this:
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
label = EditorGUI.BeginProperty(position, label, property);
Rect contentPosition = EditorGUI.PrefixLabel(position, label);
if (position.height > 16f) {
position.height = 16f;
EditorGUI.indentLevel += 1;
contentPosition = EditorGUI.IndentedRect(position);
contentPosition.y += 18f;
}
contentPosition.width *= 0.75f;
EditorGUI.indentLevel = 0;
EditorGUI.PropertyField(contentPosition, property.FindPropertyRelative("position"), GUIContent.none);
contentPosition.x += contentPosition.width;
contentPosition.width /= 3f;
EditorGUIUtility.labelWidth = 14f;
EditorGUI.PropertyField(contentPosition, property.FindPropertyRelative("color"), new GUIContent("C"));
EditorGUI.EndProperty();
}
refrence: http://catlikecoding.com/unity/tutorials/editor/custom-data/
but, i wanna have more than one line in every elements. like this:
can you help me to do this? thanks.
drawer-color.png
(15.0 kB)
drawer-color2.png
(20.7 kB)
Comment
Best Answer
Answer by afra-frantic · Dec 06, 2016 at 04:06 PM
Use the GetPropertyHeight method to specify how much height you need. It's explained in "Claiming an Extra Line".
Your answer
Follow this Question
Related Questions
Property drawer stops variables from being read 0 Answers
What does "Invalid serialized file header" even mean and how to get rid of it? 1 Answer
Serializable settings for custom PropertyDrawer 1 Answer
Can't use .Add-Function for List 1 Answer
Serialize Custom Abstract Class (No-MonoBehaviour / No-ScriptableObject) 1 Answer