Skip to content

(Feature) Custom PropertyDrawer for Unity Editor #12

@luaye

Description

@luaye

Would you consider adding a custom property drawer for unity editor inspector?
Something like this works:

[CustomPropertyDrawer(typeof(fp))]
    public class FpPropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var rawProperty = property.FindPropertyRelative("m_rawValue");
            var fixedValue = fp.FromRaw(rawProperty.longValue);
            var floatValue = EditorGUI.FloatField(position, label, (float)fixedValue);
            fixedValue = (fp) floatValue;
            rawProperty.longValue = fixedValue.RawValue;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions