Esempio n. 1
0
        private IValuePresentation GetValuePresentation(IObjectValueRole <TValue> serializedPropertyRole,
                                                        SerializedPropertyKind propertyType,
                                                        IPresentationOptions options,
                                                        out string extraDetail)
        {
            extraDetail = null;

            var valueProperty  = GetValueFieldName(propertyType);
            var valueReference = valueProperty == null ? null : serializedPropertyRole.GetInstancePropertyReference(valueProperty);

            if (propertyType == SerializedPropertyKind.Enum)
            {
                extraDetail = SerializedPropertyHelper.GetEnumValueIndexAsEnumName(serializedPropertyRole, valueReference, options);
            }
            else if (propertyType == SerializedPropertyKind.Character)
            {
                extraDetail = SerializedPropertyHelper.GetIntValueAsPrintableChar(valueReference, options);
            }
            else if (propertyType == SerializedPropertyKind.Integer)
            {
                var type = serializedPropertyRole.GetInstancePropertyReference("type")?.AsStringSafe(options)
                           ?.GetString();
                if (type == "char")
                {
                    extraDetail = SerializedPropertyHelper.GetIntValueAsPrintableChar(valueReference, options);
                }
            }

            return(valueReference?.ToValue(ValueServices)?.GetValuePresentation(options));
        }
Esempio n. 2
0
        private static string GetValueFieldName(SerializedPropertyKind propertyType)
        {
            switch (propertyType)
            {
            case SerializedPropertyKind.Integer: return("longValue");

            case SerializedPropertyKind.Boolean: return("boolValue");

            case SerializedPropertyKind.Float: return("doubleValue");

            case SerializedPropertyKind.String: return("stringValue");

            case SerializedPropertyKind.Color: return("colorValue");

            case SerializedPropertyKind.ObjectReference: return("objectReferenceValue");

            case SerializedPropertyKind.LayerMask: return("intValue");

            case SerializedPropertyKind.Enum: return("enumValueIndex");

            case SerializedPropertyKind.Vector2: return("vector2Value");

            case SerializedPropertyKind.Vector3: return("vector3Value");

            case SerializedPropertyKind.Vector4: return("vector4Value");

            case SerializedPropertyKind.Rect: return("rectValue");

            case SerializedPropertyKind.ArraySize: return("intValue");

            case SerializedPropertyKind.Character: return("intValue");

            case SerializedPropertyKind.AnimationCurve: return("animationCurveValue");

            case SerializedPropertyKind.Bounds: return("boundsValue");

            // Gradient doesn't have a compact value presenter. It just shows "GradientValue" which is not useful
            // case SerializedPropertyKind.Gradient: return "gradientValue";   // NOTE: Internal property
            case SerializedPropertyKind.Quaternion: return("quaternionValue");

            case SerializedPropertyKind.ExposedReference: return("exposedReferenceValue");

            case SerializedPropertyKind.FixedBufferSize: return("intValue");

            case SerializedPropertyKind.Vector2Int: return("vector2IntValue");

            case SerializedPropertyKind.Vector3Int: return("vector3IntValue");

            case SerializedPropertyKind.RectInt: return("rectIntValue");

            case SerializedPropertyKind.BoundsInt: return("boundsIntValue");
            }
            // TODO: What to display for ManagedReference? managedReferenceValue is a setter only property
            return(null);
        }
        private IEnumerable <IValueReference <TValue> > DecorateChildren(IObjectValueRole <TValue> serializedProperty,
                                                                         IEnumerable <IValueReference <TValue> > references,
                                                                         SerializedPropertyKind propertyType,
                                                                         IPresentationOptions options)
        {
            switch (propertyType)
            {
            case SerializedPropertyKind.Enum:
                return(DecorateEnumValue(serializedProperty, references, options));

            // I was expecting string arrays to have elements with propertyType == SpecializedPropertyType.Character
            // but they instead seem to be Integer with a type == "char"
            case SerializedPropertyKind.Character:
            case SerializedPropertyKind.Integer when serializedProperty.GetInstancePropertyReference("type")?.AsStringSafe(options)?.GetString() == "char":
                return(DecorateCharacterValue(references, options));

            default:
                return(references);
            }
        }