Beispiel #1
0
        private void DrawReorderableList(Rect position, SerializedProperty property, GUIContent label)
        {
            var labelRect = new Rect(position.xMin, position.yMin, position.width, 0f);

            if (_labelOption == DNAEvaluatorList.ConfigAttribute.LabelOptions.drawLabelAsFoldout)
            {
                labelRect           = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
                property.isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, label);
            }
            else if (_labelOption == DNAEvaluatorList.ConfigAttribute.LabelOptions.drawExpandedWithLabel)
            {
                labelRect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
                EditorGUI.LabelField(labelRect, label);
            }
            if (property.isExpanded || _labelOption == DNAEvaluatorList.ConfigAttribute.LabelOptions.drawExpandedWithLabel || _labelOption == DNAEvaluatorList.ConfigAttribute.LabelOptions.drawExpandedNoLabel)
            {
                var contentRect = EditorGUI.IndentedRect(position);
                contentRect.yMin   = labelRect.yMax + _padding;
                contentRect.height = contentRect.height - labelRect.height;

                var dnaEvalListProp = property.FindPropertyRelative(DNAEVALUATORSPROPERTY);

                _dnaEvaluatorList = CachedReorderableList.GetListDrawer(dnaEvalListProp, DrawHeaderCallback, null, DrawElementCallback, DrawFooterCallback);

                _dnaEvaluatorList.DoList(contentRect);
            }
        }
        //Draws the plugins in 'By Converter' view
        private void DrawConverters()
        {
            GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));

            if (_target.PluginCount == 0)
            {
                EditorGUILayout.HelpBox("No Converters have been added yet. Use the 'Add' tool below to add some", MessageType.Info);
            }
            _convertersListProp = serializedObject.FindProperty("_plugins");

            _convertersROL = CachedReorderableList.GetListDrawer(_convertersListProp, DrawConverterListHeaderCallback, GetConverterListEntryHeightCallback, DrawConverterListEntryCallback, DrawConverterListFooterCallback);
            _convertersROL.headerHeight = 0f;
            _convertersROL.footerHeight = (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 2);
            _convertersROL.DoLayoutList();

            GUIHelper.EndVerticalPadded(3);
        }
Beispiel #3
0
        public static CachedReorderableList GetListDrawer(SerializedProperty property, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementHeightCallbackDelegate getElementHeightCallback, ReorderableList.ElementCallbackDelegate drawElementCallback,
                                                          ReorderableList.FooterCallbackDelegate drawFooterCallback         = null,
                                                          ReorderableList.AddCallbackDelegate onAddCallback                 = null, ReorderableList.RemoveCallbackDelegate onRemoveCallback   = null, ReorderableList.SelectCallbackDelegate onSelectCallback = null,
                                                          ReorderableList.ChangedCallbackDelegate onChangedCallback         = null, ReorderableList.ReorderCallbackDelegate onReorderCallback = null, ReorderableList.CanRemoveCallbackDelegate onCanRemoveCallback = null,
                                                          ReorderableList.AddDropdownCallbackDelegate onAddDropdownCallback = null)
        {
            if (property == null)
            {
                throw new System.ArgumentNullException("property");
            }
            if (!property.isArray)
            {
                throw new System.ArgumentException("SerializedProperty must be a property for an Array or List", "property");
            }

            int hash = GetPropertyHash(property);
            CachedReorderableList lst;

            if (_lstCache.TryGetValue(hash, out lst))
            {
                lst.ReInit(property.serializedObject, property);
            }
            else
            {
                lst             = new CachedReorderableList(property.serializedObject, property);
                _lstCache[hash] = lst;
            }
            lst.drawHeaderCallback    = drawHeaderCallback;
            lst.elementHeightCallback = getElementHeightCallback;
            lst.drawElementCallback   = drawElementCallback;
            lst.drawFooterCallback    = drawFooterCallback;
            lst.onAddCallback         = onAddCallback;
            lst.onRemoveCallback      = onRemoveCallback;
            lst.onSelectCallback      = onSelectCallback;
            lst.onChangedCallback     = onChangedCallback;
            lst.onReorderCallback     = onReorderCallback;
            lst.onCanRemoveCallback   = onCanRemoveCallback;
            lst.onAddDropdownCallback = onAddDropdownCallback;

            return(lst);
        }