public void SetPolymorphicElementDrawCallback(StratusSerializedField serializedProperty)
        {
            this.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                if (!serializedProperty.isExpanded)
                {
                    return;
                }

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

                // Draw the element
                Rect position = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
                if (this.drawElementTypeLabel)
                {
                    EditorGUI.LabelField(position, elementType.Name, elementLabelStyle);
                    position.y += StratusEditorUtility.lineHeight;
                }
                drawer.DrawEditorGUI(position, element);
            };
        }
        public void SetPolymorphicElementHeightCallback(StratusSerializedField serializedProperty)
        {
            this.elementHeightCallback = (int indexer) =>
            {
                if (!serializedProperty.isExpanded)
                {
                    return(0);
                }
                else
                {
                    StratusSerializedEditorObject.ObjectDrawer drawer = StratusSerializedEditorObject.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 (this.drawElementTypeLabel)
                    {
                        height += StratusSerializedEditorObject.DefaultObjectDrawer.lineHeight;
                    }

                    return(height);
                }
            };
        }
 //------------------------------------------------------------------------/
 // Methods
 //------------------------------------------------------------------------/
 /// <summary>
 /// Draws a field using EditorGUILayout based on its members,
 /// (without using SerializedProperty)
 /// <returns>True if the field was changed</returns>
 public static bool Field(FieldInfo field, object target)
 {
     return(StratusSerializedEditorObject.GetFieldDrawer(field).DrawEditorGUILayout(target));
 }
Пример #4
0
 //------------------------------------------------------------------------/
 // Messages
 //------------------------------------------------------------------------/
 protected override void OnSelectionChanged()
 {
     base.OnSelectionChanged();
     eventObject     = (Stratus.StratusEvent)Utilities.StratusReflection.Instantiate(selectedClass);
     serializedEvent = new StratusSerializedEditorObject(eventObject);
 }