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; }
public VariableNameAttributeInspector(Metadata metadata) : base(metadata) { if (metadata.definedType != typeof(string)) { throw new NotSupportedException($"'{nameof(InspectorVariableNameAttribute)}' can only be used on strings."); } direction = metadata.GetAttribute <InspectorVariableNameAttribute>().direction; }
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); } }
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); }
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); }