Esempio n. 1
0
        public ColumnContext(AssetListConfiguration c, NamePropertyDisplay nameDisplay, AssetListWindow window)
        {
            configColumnIndex = -1;
            propertyPath      = null;
            propertyOverride  = PropertyOverride.Name;
            Func <SerializedObject, SerializedProperty> getIconProperty = null;

            if (!string.IsNullOrEmpty(c.IconPropertyPath))
            {
                if (c.IconIsArray)
                {
                    AssetListConfiguration.ArrayData propInfo = c.IconArrayPropertyInformation;
                    Func <SerializedProperty, SerializedProperty> arrayLookup = GetArrayPropertyLookup(propInfo);
                    if (arrayLookup != null)
                    {
                        getIconProperty = context =>
                        {
                            SerializedProperty iconPath = context.FindProperty(c.IconPropertyPath);
                            return(arrayLookup?.Invoke(iconPath));
                        };
                    }
                }
                else
                {
                    getIconProperty = context => context.FindProperty(c.IconPropertyPath);
                }
            }

            switch (nameDisplay)
            {
            case NamePropertyDisplay.Label:
                onGUI = (rect, sO, property) => LargeObjectLabelWithPing(rect, sO, getIconProperty, window, GUI.Label);
                break;

            case NamePropertyDisplay.NicifiedLabel:
                onGUI = (rect, sO, property) => LargeObjectLabelWithPing(rect, sO, getIconProperty, window, ReadonlyNicifiedLabelProperty);
                break;

            case NamePropertyDisplay.CenteredLabel:
                onGUI = (rect, sO, property) => LargeObjectLabelWithPing(rect, sO, getIconProperty, window, ReadonlyCenteredLabelProperty);
                break;

            case NamePropertyDisplay.NicifiedCenteredLabel:
                onGUI = (rect, sO, property) => LargeObjectLabelWithPing(rect, sO, getIconProperty, window, ReadonlyNicifiedCenteredLabelProperty);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(nameDisplay), nameDisplay, null);
            }
        }
Esempio n. 2
0
        public static string GetString(string stringValue, NamePropertyDisplay nameDisplay)
        {
            switch (nameDisplay)
            {
            case NamePropertyDisplay.Label:
            case NamePropertyDisplay.CenteredLabel:
                return(stringValue);

            case NamePropertyDisplay.NicifiedCenteredLabel:
            case NamePropertyDisplay.NicifiedLabel:
                return(ObjectNames.NicifyVariableName(stringValue));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }