Пример #1
0
        public float GetItemHeight(int index)
        {
            var property = _valuesProperty.GetArrayElementAtIndex(index);

            switch (_itemDisplay)
            {
            case ListItemDisplayType.Normal:
            {
                return(EditorGUI.GetPropertyHeight(property));
            }

            case ListItemDisplayType.Inline:
            {
                using (new EditorGUI.IndentLevelScope(1))
                    return(RectHelper.LineHeight + InlineDisplayDrawer.GetHeight(property));
            }

            case ListItemDisplayType.Foldout:
            {
                using (new EditorGUI.IndentLevelScope(1))
                {
                    var expanded = IsExpanded(index);
                    return(expanded ? RectHelper.LineHeight + InlineDisplayDrawer.GetHeight(property) : EditorGUIUtility.singleLineHeight);
                }
            }

            case ListItemDisplayType.AssetPopup:
            {
                return(AssetPopupDrawer.GetHeight());
            }
            }

            return(0.0f);
        }
Пример #2
0
        public override void Draw(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                var reloadable = property.serializedObject.targetObject as IReloadable;

                if (reloadable == null)
                {
                    Debug.LogWarningFormat(_notReloadableWarning, property.propertyPath);
                }

                if (_assetType != null)
                {
                    AssetPopupDrawer.Draw(position, label, property, _assetType, true, true, true);
                }
                else
                {
                    DrawNext(position, property, label);
                }

                if (changes.changed && reloadable != null)
                {
                    using (new EditObjectScope(property.serializedObject))
                    {
                        reloadable.OnDisable();
                        reloadable.OnEnable();
                    }
                }
            }
        }
Пример #3
0
        public void DoDefaultDraw(Rect rect, int index)
        {
            var property = List.serializedProperty.GetArrayElementAtIndex(index);

            switch (_itemDisplay)
            {
            case ListItemDisplayType.Normal:
            {
                EditorGUI.PropertyField(rect, property, GUIContent.none);
                break;
            }

            case ListItemDisplayType.Inline:
            {
                InlineDisplayDrawer.Draw(rect, property, null);
                break;
            }

            case ListItemDisplayType.Foldout:
            {
                var expanded    = IsExpanded(index);
                var labelRect   = expanded ? RectHelper.TakeLine(ref rect) : rect;
                var foldoutRect = RectHelper.TakeLeadingIcon(ref labelRect);

                using (ColorScope.Color(new Color(0.3f, 0.3f, 0.3f)))
                {
                    if (GUI.Button(foldoutRect, expanded ? _collapseButton.Content : _expandButton.Content, GUIStyle.none))
                    {
                        SetExpanded(index, !expanded);
                    }
                }

                EditorGUI.LabelField(labelRect, "Item " + index, EditorStyles.boldLabel);

                if (expanded)
                {
                    using (new EditorGUI.IndentLevelScope(1))
                        InlineDisplayDrawer.Draw(rect, property, null);
                }

                break;
            }

            case ListItemDisplayType.AssetPopup:
            {
                AssetPopupDrawer.Draw(rect, GUIContent.none, property, _assetPopupType, true, false, true);
                break;
            }
            }
        }
Пример #4
0
        private void DrawItemAsAssetPopup(Rect position, SerializedProperty listProperty, int index)
        {
            var property = listProperty.GetArrayElementAtIndex(index);

            AssetPopupDrawer.Draw(position, GUIContent.none, property, _assetListType, true, false, true);
        }
Пример #5
0
 private float GetItemAssetPopupHeight(int index)
 {
     return(AssetPopupDrawer.GetHeight());
 }