Skip to content

(Feature) Custom PropertyDrawer for Unity Editor #12

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;
        }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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