Exemple #1
0
        public void SetPolymorphicElementDrawCallback(StratusOdinSerializedProperty serializedProperty)
        {
            this.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                if (!serializedProperty.isExpanded)
                {
                    //EditorGUI.LabelField(rect, elementType.Name, elementLabelStyle);
                    //GUI.enabled = index == count;
                    return;
                }

                // Get the drawer for the element type
                var  element     = serializedProperty.GetArrayElementAtIndex(index);
                Type elementType = element.GetType();
                SerializedSystemObject.ObjectDrawer drawer = SerializedSystemObject.GetObjectDrawer(elementType);

                // Draw the element
                Rect position = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
                if (drawElementTypeLabel)
                {
                    EditorGUI.LabelField(position, elementType.Name, elementLabelStyle);
                    position.y += StratusEditorUtility.lineHeight;
                }
                drawer.DrawEditorGUI(position, element);
            };
        }
Exemple #2
0
 public void SetPolymorphicElementHeightCallback(StratusOdinSerializedProperty serializedProperty)
 {
     elementHeightCallback = (int indexer) =>
     {
         if (!serializedProperty.isExpanded)
         {
             return(0);
             //return SerializedSystemObject.ObjectDrawer.lineHeight;
         }
         else
         {
             SerializedSystemObject.ObjectDrawer drawer = SerializedSystemObject.GetObjectDrawer(serializedProperty.GetArrayElementAtIndex(indexer));
             float height = drawer.height;
             // We add an additional line of height since we are drawing a label for polymorphic list
             if (drawElementTypeLabel)
             {
                 height += SerializedSystemObject.DefaultObjectDrawer.lineHeight;
             }
             return(height);
         }
     };
 }