protected MetadataCollectionAdaptor(Metadata metadata, Inspector parentInspector)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            if (parentInspector == null)
            {
                throw new ArgumentNullException(nameof(parentInspector));
            }

            this.metadata        = metadata;
            this.parentInspector = parentInspector;

            var wideAttribute = metadata.GetAttribute <InspectorWideAttribute>();

            if (wideAttribute != null)
            {
                widthMode = wideAttribute.toEdge ? WidthMode.Edge : WidthMode.Wide;
            }
            else
            {
                widthMode = WidthMode.Thin;
            }

            listControl = new ReorderableListControl();
            listControl.ContainerStyle    = new GUIStyle(ReorderableListStyles.Container);
            listControl.FooterButtonStyle = new GUIStyle(ReorderableListStyles.FooterButton);
            listControl.ItemButtonStyle   = new GUIStyle(ReorderableListStyles.ItemButton);

            listControl.ItemRemoving += ListControlOnItemRemoving;
        }
Esempio n. 2
0
        protected Inspector(Metadata metadata)
        {
            Ensure.That(nameof(metadata)).IsNotNull(metadata);

            this.metadata = metadata;
            InitializeProfiling();
            metadata.valueChanged += previousValue => SetHeightDirty();

            warnBeforeEditingAttribute = metadata.GetAttribute <WarnBeforeEditingAttribute>();

            if (warnBeforeEditingAttribute != null)
            {
                editLocked = !warnBeforeEditingAttribute.emptyValues.Any(emptyValue => metadata.value == emptyValue);
            }
        }
Esempio n. 3
0
        private static float LabelWidth(Metadata metadata, float width)
        {
            var labelWidth = LudiqGUIUtility.labelWidth.value;

            var wideAttribute = metadata.GetAttribute <InspectorWideAttribute>();

            if (wideAttribute != null)
            {
                if (wideAttribute.toEdge)
                {
                    labelWidth = LudiqGUIUtility.currentInspectorWidth;
                }
                else
                {
                    labelWidth = width;
                }
            }

            return(labelWidth);
        }
Esempio n. 4
0
        public static GUIContent ProcessLabel(Metadata metadata, GUIContent label)
        {
            if (label == GUIContent.none)
            {
                return(label);
            }

            if (label == null)
            {
                var attribute = metadata.GetAttribute <InspectorLabelAttribute>();

                if (attribute != null)
                {
                    label = new GUIContent(attribute.text, attribute.image ?? metadata.label.image, attribute.tooltip ?? metadata.label.tooltip);
                }
                else
                {
                    label = metadata.label ?? GUIContent.none;
                }
            }

            return(label);
        }